Click on the Comments to view the Answers

Wednesday, January 20, 2010

Datastep Execution

data x;
set a;
length name $ 5;
retain name 'David';
do i=1 to 5;
initial = substr(name,1,1);
end;
if initial .ne. 'D' then delete;
run;

How many times is this data step executed based on the datasets below?

data a
--------
name age
Bob   35
Jason 57
John  79

data b
-------
name  age
Bob    2
Dawn  4

data c
-------
name   age
Dawn   30
Bob     35
Jill        40
Jason    45
deb       50


Pick the answer-
a) 2
b) 3
c) 5
d) 10

Check the comments below for answers....

6 comments:

SASGuru said...

The Data set has 3 observations....
The datastep executes till it reaches the end of the observations...Here we are look for the iteration counts.....ie. 3

Kalyani bade said...

plz explain it in detail i didnt get

manju said...

I too couldnt get it either

Unknown said...

plz explain it again....i also didnt get it

Unknown said...

Should the answer be A? Logic: There are a total of 10 observations and 8 would be deleted because the initial="D" in only two observations (Dawn in data B and data C). The observation "deb" in data C does not have a capital "D" so will be deleted. Therefore answer is A.

Mattias said...

set 'data a' has only three observations, this must be what is to be counted. 'data b' and data c' is never used. Am I correct?

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