Click on the Comments to view the Answers

Monday, January 25, 2010

Base 50

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

11 comments:

SASGuru said...

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.

Vikas said...

Answer is B.

Unknown said...

concur with B

Geoff said...

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.

shalini said...

I think the answer should be B as we have the trailing @ after the first variable

Unknown said...

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.

neurosas said...

if style = 'CONDO' or style = 'RANCH' ; w/o then
only 3 observations; SASGURU can you comment on this

Leventumps said...

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".

Unknown said...

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

Unknown said...

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.

Unknown said...

To Fu,
Very effective example, with DO and W/O DO.
Thank You

Post a Comment



Technology Top Blogs On our way to 1,000,000 rss feeds - millionrss.com Hihera.com Blog Directory - OnToplist.com blogarama - the blog directory Blog Directory
Disclaimer

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are trademarks of their respective companies.

This blog is not responsible for any kind of copyright violation. This blog just collects the links hosted or posted by other servers/people/search engines.The creator of this page or the ISP(s) hosting any content on this site take no responsibility for the way you use the information provided on this site.If anybody has any copyright claim on it and doesn’t wish the information provided to be shown on our site, please do respond to this email. We shall remove them off immediately. Any inconvenience is regretted. Please do mention your exact grievance/problems with respect to certain third party links. We assure you that appropriate action will be taken off. Thank you