The following SAS program is submitted:
data numrecords;
infile ‘file specification’;
input@1 patient $15.
relative$ 16-26@;
if relative = ‘children’ then
input @54 diagnosis $15. @;
else if relative = ‘parents’ then
input @28 doctor $15.
clinic $ 44-53
@54 diagnosis $15. @;
input age;
run;
in this raw data why only 2 raw data records are read during each iteration of data step execution , it is mentioned input age so it should be 1 raw data record read not two . plz help
Hi:
If this is a quiz or interview question, the answer is 1 raw data record is being read on each iteration of the DATA step execution. Notice how each INPUT statement ends with a trailing @ except for the last INPUT for age, which releases the held data row.
If you mock up the data based on the program, this is what you get.
Cynthia
The following SAS program is submitted:
data numrecords;
infile 'file specification';
input @1 patient $15.
relative $ 16-26 @;
if relative = 'children' then input @54 diagnosis $15. @;
else if relative = 'parents' then input @ 28 doctor $ 15.
clinic $ 44-53
@54 diagnosis $ 15. @;
input age;
run;
how many raw data records are read during each iteration of the DATA step execution?
A. 1
B. 2
C. 3
D. 4
Can anyone please explain what can be the answer and why?
Hi:
If this is a quiz or interview question, the answer is 1 raw data record is being read on each iteration of the DATA step execution. Notice how each INPUT statement ends with a trailing @ except for the last INPUT for age, which releases the held data row.
If you mock up the data based on the program, this is what you get.
Cynthia
I like your answer, you analysed the question carefully to understand what the author tried to achieve.
The log often prints messages about what happened. For example, you might see a message about SAS moving on to a new line when it reached past the end of the current line.
Did you read the log? Do you still have it available to post here?
If the data in the external file is not sensitive then paste it into a code box opened with the forums {I} icon. Text pasted in the main message boxes can get reformatted removing white space such that the result may not actually represent your data.
Perhaps you are reading past the end of the line?
Try adding the TRUNCOVER option to your INFILE statement.
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!
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.