How to solve the question below?
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)
@vincentgoh88 wrote:
How to solve the question below?
By executing the code an reading the created dataset.
Be aware that text posted into the main message windows may not actually reflect what you intended if you used a copy/paste.
123 789
123 789
The text was copied from the SAS Editor and pasted above. The first bit the leading blanks and 2 blanks between 3 and 7 were removed by the formum software. The second bit was pasted into a code box opened with the forum's {I} icon.
Why do I mention that? We cannot actually be sure that the data step we see was the actual data step that should be considered for answering questions. And you specific question answer would change drastically depending on the number and position of blanks.
Another obnoxious bit is that the data step code you pasted will not actually run.
data test; infile ‘employee’; input employee_name $ 1-4; if employee_name = ‘Ruth’ then input idnum 10-11; else input age 7-8; run;
The quotes shown that are angled will generate errors such as:
6 if employee_name = ‘Ruth’ then input idnum 10-11; - 390 76 ERROR 390-185: Expecting an relational or arithmetic operator. ERROR 76-322: Syntax error, statement will be ignored.
because the characters the SAS compiler expects for quotes are either ' or "
It should be 22.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: