BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fiery
Obsidian | Level 7

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!

 

Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

View solution in original post

9 REPLIES 9
Rick_SAS
SAS Super FREQ

You are correct. The program will give a syntax error unless it has two END statements.

Fiery
Obsidian | Level 7

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.

 

Rick_SAS
SAS Super FREQ

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.

Fiery
Obsidian | Level 7

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. 🙂 

 

 

Capture.JPG

Rick_SAS
SAS Super FREQ

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!

Fiery
Obsidian | Level 7

Thanks! 🙂 

Have a good day! 

Karen_sas11
Calcite | Level 5

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

Rick_SAS
SAS Super FREQ

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.

Karen_sas11
Calcite | Level 5

Thanks a lot!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 9 replies
  • 1269 views
  • 1 like
  • 3 in conversation