Click on the Comments to view the Answers

Sunday, January 24, 2010

Base 15

The contents of the raw data file EMPLOYEE are listed below:


--------10-------20-------30
Ruth  39 11 (39 starts at col-7 and 11 at col-10)

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"?
A. 30
B. 33
C. 40
D. . (missing numeric value)

7 comments:

SASGuru said...

Answer: C

data work.TEST;
infile cards;
input employee_name $ 1-4;
if employee_name = 'Sue' then input age 7-8;
else input idnum 10-11;
put _all_;
cards;
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
;
run;

employee_name=Ruth age=. idnum=22 _ERROR_=0 _N_=1
employee_name=Sue age=40 idnum=. _ERROR_=0 _N_=2

Unknown said...

hi guru,
could u please explain, why is it writing the data like this?
and what should have been the correct statements to get data entered correctly?

V.V. said...

The program accepts the name first and the performs the if operation. Since you are not having the @ sign to hold on to the record till for the if condition to be tested, the next input record is read the value of idnum is written as 22 for Ruth and the value of age for Sue is 40. Add the @ sign to hold the record at the input statement.

Eg:

data test;
infile cards;
input employee_name $ 1-4 @;
if employee_name = 'Sue' then input age 7-8;
else input idnum 10-11;
cards;
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
;run;

siva said...

Thanks Mr.V.V Its Great helpful

neurosas said...

VV tHANK YOU EXCELLENT SUGGESTION, GREAT HELP
ONE SINGLE TRAILING (@) WILL DO THE MAGIC

Unknown said...

thanks VV for this explanation. It seems easy but will make ur mind work. ;)

Unknown said...

hi guru,
please explain pdv being formed in each step and how it holds the values in question.

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