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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
gauthamk28
Obsidian | Level 7
If expression then do;
Executable statements;
End;
Else do;
Executable statements;
End;

View solution in original post

4 REPLIES 4
Reeza
Super User

You're missing a semicolon after the second DO statement. 

 

See the examples in the documentation 🙂 

 

http://support.sas.com/documentation/cdl/en/basess/68381/HTML/default/viewer.htm#p0pcj5ajwyngron1wls...

 

Google seems broken these days. Consider searching directly at either lexjansen.com, communities.sas.com or support.sas.com

csetzkorn
Lapis Lazuli | Level 10
Thanks I found the link you provided via google but it did not show what I was after (e.g. not using else if). gauthamk28 provided what I was after. Thanks anyway.
Reeza
Super User

This one has a fourth example that is interesting, I wouldn't have expected that to work. 

 

http://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#n1j60arf27ll4nn...

 

if x=0 then  
   if y ne 0 then put 'X ZERO, Y NONZERO'; 
   else put 'X ZERO, Y ZERO';
else put 'X NONZERO';

 

 

 

 

gauthamk28
Obsidian | Level 7
If expression then do;
Executable statements;
End;
Else do;
Executable statements;
End;

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
  • 4 replies
  • 883 views
  • 2 likes
  • 3 in conversation