DATA Step, Macro, Functions and more

When did it become valid to use %IF in open code?

Accepted Solution Solved
Reply
Highlighted
Super User
Super User
Posts: 8,069
Accepted Solution

When did it become valid to use %IF in open code?

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.

 

 


Accepted Solutions
Solution
2 weeks ago
Respected Advisor
Posts: 2,981

Re: When did it become valid to use %IF in open code?


All Replies
Super User
Posts: 6,751

Re: When did it become valid to use %IF in open code?

Not working in SAS 9.4 TS1M2

 

But an exciting find nonetheless.

Respected Advisor
Posts: 2,981

Re: When did it become valid to use %IF in open code?

Not working in SAS 9.4 TS1M4

--
Paige Miller
Contributor
Posts: 29

Re: When did it become valid to use %IF in open code?

not working for SAS9.4M4 :/

 

is working in SAS9.4M5 (y)

Super User
Posts: 10,209

Re: When did it become valid to use %IF in open code?

Quite obviously something new with 9.4M5. Checked it here on AIX.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Community Manager
Posts: 3,424

Re: When did it become valid to use %IF in open code?

Posted in reply to KurtBremser

Good find! 

 

Blog post here:

Thanks to @Tom for the nudge.

Solution
2 weeks ago
Respected Advisor
Posts: 2,981

Re: When did it become valid to use %IF in open code?

Super User
Posts: 10,209

Re: When did it become valid to use %IF in open code?

Posted in reply to PaigeMiller

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Respected Advisor
Posts: 2,981

Re: When did it become valid to use %IF in open code?

Posted in reply to KurtBremser

@KurtBremser 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
SAS Employee
Posts: 3

Re: When did it become valid to use %IF in open code?

Posted in reply to PaigeMiller

I would expect iterative %DO in open code.

New Contributor
Posts: 2

Re: When did it become valid to use %IF in open code?

Posted in reply to PaigeMiller

Does the same work in SAS Enterprise Guide version 7.1?

Super User
Super User
Posts: 8,069

Re: When did it become valid to use %IF in open code?


@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
Super User
Posts: 10,209

Re: When did it become valid to use %IF in open code?

In EG, right-click on the opened server in the server list, select Properties, then Software.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 10,209

Re: When did it become valid to use %IF in open code?


@Monk wrote:

Does the same work in SAS Enterprise Guide version 7.1?


The EG version does not matter. You need SAS 9.4M5 in the backend.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 13 replies
  • 442 views
  • 8 likes
  • 8 in conversation