Run the step first. Then apply your knowledge about "data step concepts" (if this is not yet present, get it through googling for the phrase and study the respective SAS documentation) to the result, and you will arrive at the answer.
The intent of such exercises is that you find the answer (and thus hone your skills), not somebody else.
Run the step first. Then apply your knowledge about "data step concepts" (if this is not yet present, get it through googling for the phrase and study the respective SAS documentation) to the result, and you will arrive at the answer.
The intent of such exercises is that you find the answer (and thus hone your skills), not somebody else.
Since you didn't add @ at the end of "input employee_name $ 1-4; ".
that means point will go to the next row.
it should be 22 .
Hi:
To test the program, you either would have needed to make a file called "employee" and type the datalines into the file or modify the program slightly to use the INFILE DATALINES technique for reading in test data. Here's an example of using INFILE DATALINES:
data test;
infile datalines;
input employee_name $ 1-4;
if employee_name = 'Ruth' then input idnum 10-11;
else input age 7-8;
datalines;
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
;
run;
proc print data=test;
title '1) After running original program';
run;
We do show this technique in our Programming 1 class and the technique of using DATALINES to provide a program with "instream" data is well documented.
Then, once you run the program and see that KSharp was correct, that the value would be 22 -- as shown below:
--then you can read about using the single trailing @ sign to modify the behavior of the INPUT statement.
Every time an INPUT statement is encountered in a program, (EVERY time), a new row or new dataline is loaded into the INPUT buffer area. So without any other controls in place, SAS will go to a new dataline after reading the name on the first row.
Cynthia
Thanks a lot for showing the program in detail .I did something when writing this program in SAS studio.I'll fix it and run.
I agree with @Kurt_Bremser that you really should first experiement and see if you can answer the questions yourself.
If there really are blank lines between each record, the code won't even run. And, if there aren't blank lines between each record, and the data are exactly the way you entered them, then the answer is 2 as SAS will try to read two digits beginning in column 10, but only one digit exists there.
Art, CEO, AnalystFinder.com
ans is 22. because when you put input statement again after then.. then it will take value of next variable.(as per my knowledge)
It is a very good idea to post code and example data using codeboxes opened with the forum {i} menu icon.
As posted your code won't produce very similar results as the forum window has likely inserted additional blank lines.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.