The contents of the raw data file are listed below:
----|----10----|----20----|----30
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
The following SAS program is submitted:
data test;
infile 'employee';
input employee_name $ 1-4;
if employee_name='Sue' then input age 7-8;
else input idnum 10-11;
run;
Which one of the following values does the variable AGE contain when the name of the employee is 'Sue'?
假设这是SAS代码:
data a;
input name $ 1-4 ;
if name='Sue' then input age 6-7 ;
else input id 9-10;
datalines;
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
;
run;
首先读入Ruth作为name的值。由于name的值不是Sue,则从下一行输入id,其值22,也就是列输入的位置。此时,第一个观测读写完成。对于Sue,从下一行的指定列读入age,为40,id由于没有赋值则为缺失值。出现一个input,则会往下移动一行,故Jose那一行就只读了个id的值。所以最后的数据集只有两行,结果为,
name age id
Ruth . 22
Sue 40 .