I did numerous google seraches but could not find an answer. What is the syntax, if I have several statements in the if and the then part of an if the statement? This is some pseudo code:
if /* some condition */ then do; /* statements */ end; else do /* statements */ end;
The if part is fine but I am not sure about the then part.
You're missing a semicolon after the second DO statement.
See the examples in the documentation 🙂
Google seems broken these days. Consider searching directly at either lexjansen.com, communities.sas.com or support.sas.com
This one has a fourth example that is interesting, I wouldn't have expected that to work.
if x=0 then
if y ne 0 then put 'X ZERO, Y NONZERO';
else put 'X ZERO, Y ZERO';
else put 'X NONZERO';
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.