Given the raw data file EMPLOYEE:
----I----1 0---I----20---I----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 = `Ruth' then input idnum 10-11;
else input age 7-8;
run;
What value does the variable IDNUM contain when the name of the employee is "Ruth"?
A. 11
B. 22
C. 33
D. (missing numeric value)
Thanks for answering in advance,
Hi:
There is a HUGE difference between showing the data in a "fixed pitch" font and showing the data in a proportional spaced font, especially when your INPUT statement uses column positions.
Again, to find out the answer to this question, you would type the data into a file, save the file as EMPLOYEES on your hard drive. Then probably amend the INFILE statement to use a fully qualified path. So, for example, if you save EMPLOYEES into c:\temp, the only modification would be to alter the INFILE statement: INFILE 'C:\temp\employees';
Instead of answering the question for you, I am curious what results you discovered when you ran the program.
cynthia
I did run the program and it gave a data error. See log message below:
NOTE: Invalid data for idnum in line 3 1-2.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9
3 Jose 32 22 10
employee_name=Ruth idnum=. age=. _ERROR_=1 _N_=1
NOTE: Invalid data for age in line 7 1-2.
7 John 40 44 10
employee_name=Sue idnum=. age=. _ERROR_=1 _N_=2
What is unconvincing is the IF-THEN logic being used, which obviously makes me question the authenticity of online sample papers available for Base SAS exam.
if employee_name = `Ruth' then input idnum 10-11;
else input age 7-8;
Thanks, anyways, Cynthia.
Forgot to add that after running the program, the output window showed missing values for the variables IDNUM and AGE. NAMES did appear though.
Gavy
Cynthia and everyone,
I am preparing for Base SAS certification exam and was looking for a few practice papers. Would you like to recommend any useful sites, links from where I could access sample questions either free of charge or maybe paid(but not too expensive!)?
Much Appreciated!
Gavy
hi cynthia,
please explain the how pointer is reading the data. i am unable to comprehend the outcome. please help.
Unless the actual question has an indication that the lines are shorter than 11 characters then you cannot tell if the right answer is D or None of the above.
If we replace the spaces with periods the actual input line for "Ruth" could be either of the lines below. In the first the value will be missing as it will try to read from the next line when it runs out of characters. In the second example the value will be 1 since it reads '1 ' from columns 10 and 11.
----|----10---|----20---|----30
Ruth.39.11
Ruth.39.11....................
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.