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

With SAS 9.4M5 I can now submit %IF statement in open code.

When did this become valid?  I cannot find a reference any where.

 

Note that it requires that you use a %DO/%END block as the statement to run in the %THEN or %ELSE clause.

 

 74         * test macro if in open code;
 75         %if (1=1) %then %do;
 76         proc print data=sashelp.class; run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.05 seconds
       cpu time            0.05 seconds
       
 
 77         %end;
 78         %else %do; %put False; %end;
 79         
 80         * test macro do in open code ;
 81         %do i=1 %to 3 ;
 ERROR: The %DO statement is not valid in open code.
 82           %put &=i ;
 WARNING: Apparent symbolic reference I not resolved.
 i
 83         %end;
 ERROR: The %END statement is not valid in open code.

 

 

1 ACCEPTED SOLUTION
13 REPLIES 13
Astounding
PROC Star

Not working in SAS 9.4 TS1M2

 

But an exciting find nonetheless.

PaigeMiller
Diamond | Level 26

Not working in SAS 9.4 TS1M4

--
Paige Miller
utrocketeng
Quartz | Level 8

not working for SAS9.4M4 😕

 

is working in SAS9.4M5 (y)

ChrisHemedinger
Community Manager

Good find! 

 

Blog post here:

Thanks to @Tom for the nudge.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
PaigeMiller
Diamond | Level 26

@Kurt_Bremser wrote:

I would have expected to see such an important change in the "What's new in SAS 9.4" guide. As of now, I couldn't find it there.


I agree. The fact that many experts in this thread were not aware of this change is surprising, in the sense that SAS did not publicize this as much as I think they should have.

 

What's next? IML language allowed in a data step? SQL language allowed in PROC GLM? Lights at Wrigley Field?

--
Paige Miller
LeonidBatkhan
Lapis Lazuli | Level 10

I would expect iterative %DO in open code.

Monk
Fluorite | Level 6

Does the same work in SAS Enterprise Guide version 7.1?

Tom
Super User Tom
Super User

@Monk wrote:

Does the same work in SAS Enterprise Guide version 7.1?


It depends on what version of SAS your session is using.  I am not sure if there is menu item in EG to find out, but you could just ask SAS to tell you by checking the SYSVLONG automatic macro variable.

744  %put &sysvlong;
9.04.01M5P091317

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
  • 13 replies
  • 12987 views
  • 12 likes
  • 8 in conversation