I am new to SAS, I came cross this question online, I see 2 DO loop statements here, but there is only one "End" statement. Shouldn't it include 2 "End" statements, one for each DO loop? Thanks!
I think they are asking for the output IF the program was correctly written. In that case, the correct answer is C because the last observation is written. If you want all observations, put an OUTPUT statement inside the innermost loop.
You are correct. The program will give a syntax error unless it has two END statements.
Hi Rick, thanks for your reply. In this case, there should be no observation be written. right? I would choose D as the answer. But the system says the correct answer is C.
I think they are asking for the output IF the program was correctly written. In that case, the correct answer is C because the last observation is written. If you want all observations, put an OUTPUT statement inside the innermost loop.
Rick, I agree with you. I think this question is to check if you know 'OUTPUT' statement. without the OUTPUT statement, it will only show the last observation. However, for curiosity I tried to write this program in SAS, Log shows an Error and a Warning as I expected.
If this is a real exam, I will be confused, what is it trying to test us: OUTPUT statement or End statement. I am having an exam next week, wish myself goodluck. 🙂
Yes, I agree with you. The first task of the test creator is to make the question clear. The creator of this test did not proofread sufficiently. You have every right to feel confused and frustrated by this question.
I suspect and hope that your test next week will be clearer. Best wishes for a successful exam!
Thanks! 🙂
Have a good day!
Hello Rick,
So do you mean by default only the last observation is written unless you put a implicit output in the do end statement to list all loops?
Regards,
Karen
By default, every DATA step contains an implicit OUTPUT statement at the end the step (just before the RUN statement). That is usually what you want when the DATA step contains a SET statement or an INFILE statement or a DATALINES statement. However, this example does not contain any of the usual data input statements. If you want to see each iteration of the DO loop, you should insert an OUTPUT statement at an appropriate location.
Thanks a lot!
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.