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

I just came across code that looks like this:

data test;
input x1;
select (x1);
  when (1) do
    x2 = 1;
    x3 = 1;
  end;
  otherwise;
end;
datalines;
1
0
;

and I immediately thought "ERROR because of missing semicolon!", but this code works, and it even works as obviously intended.

Does anybody know why SAS does not complain here?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Yes, it's the iterative DO statement (with x2 as the index variable), just written in a "peculiar" way, not a DO-END block.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Yes, it's the iterative DO statement (with x2 as the index variable), just written in a "peculiar" way, not a DO-END block.

Kurt_Bremser
Super User

Oh yes, that's it! It works, but it nicely fits a schlockmercenary quote I posted yesterday:

"When it's stupid and it works, it's still stupid, and you're lucky"

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 542 views
  • 3 likes
  • 2 in conversation