楼主: mingyuqi
2752 5

[问答] 求问大神SAS Base 70题里面的第24题 [推广有奖]

  • 0关注
  • 0粉丝

大专生

50%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
3 点
热心指数
3 点
信用等级
3 点
经验
387 点
帖子
25
精华
0
在线时间
42 小时
注册时间
2016-1-17
最后登录
2023-8-13

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
24.Given the following raw data records:

  ----|----10---|----20---|----30
  Susan*12/29/1970*10
  Michael**6

The following output is desired:

  Obs  employee   bdate  years
   1   Susan       4015    10
   2   Michael        .     6

Which SAS program correctly reads in the raw data?
        A.
data employees;
   infile 'file specification' dlm='*';
   input employee $ bdate : mmddyy10. years;
run;

     B.
data employees;
   infile 'file specification' dsd='*';
   input employee $ bdate mmddyy10. years;
run;

     C.
data employees;
   infile 'file specification' dlm dsd;
   input employee $ bdate mmddyy10. years;
run;

     D.
data employees;
   infile 'file specification' dlm='*' dsd;
   input employee $ bdate : mmddyy10. years;
run;
-------------------------------------


答案是D, 我能明白dsd dlm在这里面连用的效果。但是有两点不解, 1)是format input的用法,为什么是bdate : mmddyy10.而不是bdate  mmddyy10. 为什么这里需要一个冒号?

2)是B项直接用dsd='*'是不符合规范的吗?

谢谢~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:SAS base Base Employees following correctly employees following Michael desired records

沙发
graceyudy 发表于 2016-3-9 11:51:54 |只看作者 |坛友微信交流群
我能回答问题2,只用dlm=‘*’,没有加dsd,不是不规范,而是会把第二行record的**认为是一个delimiter,而不会读出missing value,加上dsd才能把连续两个delimiter认作中间有个missing value。
第一个问题,似乎format input必须加冒号。不加冒号的话算是list input。

使用道具

藤椅
SASbase2015 发表于 2016-3-9 12:25:04 |只看作者 |坛友微信交流群
To read nonstandard data values and character values that are longer than 8 characters, but which contain no embedded blanks.

使用道具

板凳
pan_shirley 发表于 2016-6-20 21:40:57 |只看作者 |坛友微信交流群
graceyudy 发表于 2016-3-9 11:51
我能回答问题2,只用dlm=‘*’,没有加dsd,不是不规范,而是会把第二行record的**认为是一个delimiter,而 ...
谢谢楼主的解答,我也想问这两个问题

使用道具

报纸
SugarJoy 发表于 2019-3-30 16:55:34 |只看作者 |坛友微信交流群
冒号那个我还是不太懂

使用道具

地板
xiaopingN 发表于 2019-4-2 01:05:43 |只看作者 |坛友微信交流群
SugarJoy 发表于 2019-3-30 16:55
冒号那个我还是不太懂
加入冒号后,属于modified list input, 整个输入仍然是list input, 而且同时还 informat了变量bdate。如果去掉冒号,bdate 输入方式就变成 formated input, 影响了后面的变量years的读入。这时 如果不定义读入光标的位置,就会紧接着bdate 下一格读入,而不是在分隔符*后读入。
已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
admin_kefu + 20 + 2 + 2 + 2 热心帮助其他会员

总评分: 论坛币 + 20  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 22:50