全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
8292 8
2011-02-04
41.A raw data file is listed below.
1---+----10---+----20---+---
01/05/1989 Frank 11
12/25/1987 June 13
01/05/1991 Sally 9
The following SAS program is submitted using the raw data file as input:
data work.family;
infile 'file-specification';
input @1 date_of_birth mmddyy10.
@15 first_name $5.
@25 age 3;
run;
proc print data=work.family noobs;
run;
Which one of the following is the result?
a. The program executes, but the age values are missing in the output.
b. The program executes, but the date values are missing in the output.
c. The program fails to execute because the age informat is coded incorrectly.
d. The program fails to execute because the date informat is coded incorrectly.
Correct answer: a



112. The contents of the raw data file SIZE are listed below:
----|----10---|----20---|----30
72 95
The following SAS program is submitted:
data test;
infile 'size';
input @1 height 2. @4 weight 2;
run;
Which one of the following is the value of the variable WEIGHT in the output data set?
A. 2
B. 72
C. 95
D. . (missing numeric value)

Answer: A

这两个题都是input format 缺少一个. ,为什么结果不一样(上机测试结果证明答案没错),为什么@25 age 3; age的值是missing 而不是3?请高手解惑,谢谢!

测试用code:

data work.family;
input @1 date_of_birth mmddyy10.
@15 first_name $5.
@25 age 3;
cards;
01/05/1989 Frank 11
12/25/1987 June  13
01/05/1991 Sally 9
;
run;
proc print data = family;
run;

data test;
infile cards;
input @1 height 2. @4 weight 2;
cards;
72 95
;
run;
proc print data = test;
run;
二维码

扫码加我 拉你入群

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

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

全部回复
2011-2-4 07:49:13
不懂啊。。。。
二维码

扫码加我 拉你入群

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

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

2011-2-4 22:54:50
没人回答吗?马上就要考了呀,呼唤高手
二维码

扫码加我 拉你入群

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

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

2011-2-6 14:13:46
1# 媚小妖
呵呵,高手过年的时候都比较忙嘛~ 我是只菜鸟,仅说说个人理解~ :-)
这里input format读数字格式时是缺少了 “.” ,但个人认为不是将缺少 “.” 的数字当数值直接赋给前面的变量,而是将其看做“列指针”。
112题weight之所以是2,并不是把“input @1 height 2. @4 weight 2;”最后的那个2赋给weight,而是最后的“2”指到了“72”的“2”,如果改为“input @1 height 2. @4 weight 1;”那么weight就是7了,可以自己测试下~
41题得age就当然不是3了,之所以是missing是因为“@25 age 3;”的“3”指到第三列,即如“01/05/1989”的第3列,是“/”,对于数值型的age当然得到missing,如果改为“@25 age 2;”,测试下会发现age分别为 1,2,1了
二维码

扫码加我 拉你入群

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

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

2011-2-7 01:18:49
hssnow, 高人啊高人!我以前对这个列指针的理解全错了。惭愧!

上机测试结果果真如此。谢谢了
二维码

扫码加我 拉你入群

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

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

2012-4-12 13:28:18
thank you so much
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群