A raw data file is listed below:
RANCH,1250,2,1,Sheppard Avenue,"$64,000"
SPLIT,1190,1,1,Rand Street,"$65,850"
CONDO,1400,2,1.5,Market Street,"80,050"
TWOSTORY,1810,4,3,Garris Street,"$107,250"
RANCH,1500,3,3,Kemble Avenue,"$86,650"
SPLIT,1615,4,3,West Drive,"94,450"
SPLIT,1305,3,1.5,Graham Avenue,"$73,650"
The following SAS program is submitted using the raw data file as input:
data work.condo_ranch;
infile 'file-specification' dsd;
input style $ @;
if style = 'CONDO' or style = 'RANCH' then
input sqfeet bedrooms baths street $ price : dollar10.;
run;
How many observations does the WORK.CONDO_RANCH data set contain?
A. 0
B. 3
C. 5
D. 7
B. 3
C. 5
D. 7
11 comments:
Answer: D
Remember the trailing @ definition, the next input statement will read from the current record in the same datastep iteration…So when we are using @ the total number of iterations would be directly proportional to the number of records in the raw data file….
The input statement in line 3 has a @..but it does not have a effect here…because @ holds the current record for the same iteration in the datastep.
Answer is B.
concur with B
Concur with D. Look at the programming. Each time you go through you input the first variable, style (so that's 7 times). You only end up putting in the rest if it's condo or ranch. So you have 4 partial records and 3 full records, for a total of 7.
I think the answer should be B as we have the trailing @ after the first variable
Concur with SAS Guru and Geoff...even if the IF condition is not met (in this case it will not meet for 4 observations), it will fill up the records partially for the 3 observations with the variable "style". Answer is D.
if style = 'CONDO' or style = 'RANCH' ; w/o then
only 3 observations; SASGURU can you comment on this
SASGuru is right. I think some people might be confused because they are confusing the conditional statement for a subset. The IF statement in the data step is not a subset and therefore does not limit the observations to "condo" and "ranch".
neurosas see the statement
if style = 'CONDO' or style = 'RANCH' then
input sqfeet bedrooms baths street $ price : dollar10.;
will show values for CONDO and RANCH , but for others it will show missing values.
so there are all values for Style variable
hence answer is D : 7
The answer is D. If there was an OUTPUT statement before the RUN statement (and add a DO and END) then the answer is B.
I found a similiar question in the practice exam. Maybe it will help you understand more?
1---+----10---+----20---+---
RANCH,1250,10MAR2004
SPLIT,1190,10/20/2004
CONDO,1400,17JUN2004
TWOSTORY,1810,12/31/2004
RANCH,1500,20JAN2004
SPLIT,1615,08/19/2004
The following SAS program is submitted using this file as input:
data work.houses;
infile 'file-specification' dsd;
input style $ @;
if style='CONDO' or style='RANCH' then do;
input sqfeet saledate : date9.;
output;
end;
run;
Here there are 3 observations.
To Fu,
Very effective example, with DO and W/O DO.
Thank You
Post a Comment