BookmarkSubscribeRSS Feed
Bulleride
Obsidian | Level 7

Why and how does this code proceed?

QUESTION 
The contents of the raw data file EMPLOYEE are listed below:
----|----10---|----20---|----30
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
The following SAS program is submitted:
data test;
in file' 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)

 

Ans –C

3 REPLIES 3
Haikuo
Onyx | Level 15

This one is straightforward, without line holder @, as

input employee_ name $ 1-4 @;

The 'input' statement will move down to the next line of raw data. That is why you get '40'. With '@' in place, you get to stay on the same line, hence to get '30'.

 

Bulleride
Obsidian | Level 7
Could you please explain what happens here as there is no @, and hence it would move to the next line. But how does it pick the value 40 then?
Please elaborate this processing a bit. Thanks in advance 🙂
Haikuo
Onyx | Level 15

'40' is one line below Sue's line, so

if employee_name = 'Sue' then input age 7-8;

will move down one line, where 'John' sits, to pick up '40'.

 

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1102 views
  • 1 like
  • 2 in conversation