BookmarkSubscribeRSS Feed
VD
Calcite | Level 5 VD
Calcite | Level 5
Is there a way to pass the control from one part of the program to another, without the use of macros. I'm looking for something that would do a similar function as a 'go to' statement but is not restricted within one data step only.
Thanks.
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Yes, you can use CALL EXECUTE with IF / THEN DO / END logic in a DATA step to cause later processing conditionally. Suggest using the SAS support website for SAS-hosted DOC and supplemental technical / conference reference material.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

call execute data step site:sas.com Message was edited by: sbb
VD
Calcite | Level 5 VD
Calcite | Level 5
This is very helpful, thanks Sbb.

I'm wondering if there is any function like the html anchor whereby you can anchor a position in the code. And then once any condition is true, all the code beyond that anchor point can be executed otherwise not.

I understand that macros would make it simple to implement, but could it be done without the use of macros?
Many thanks.
V.
Cynthia_sas
SAS Super FREQ
Hi:
You might investigate the LINK statement:
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#/documentation/cdl/...

SAS also still supports the GOTO statement -- although generally, I find that GOTO is not needed if you structure your program logic correctly, using DO--ELSE and IF--THEN--DO--ELSE DO--END constructions
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#/documentation/cdl/...

And, as Scott says, CALL EXECUTE can place code in the program stack to execute when your "calling" data step program has ended. However, it really depends on what you want to do--CALL EXECUTE can execute program code (such as a PROC STEP) or could, but does not have to, invoke a macro program.

cynthia
Peter_C
Rhodochrosite | Level 12
not automatic, but effective:
1 at start point of conditional code open fileref, say, myRef
2 push conditional code to myRef using the file statement MOD option in each subsequent data step
3 once a decision to use the conditional code is made, %include that fileref with code like[pre] data ;
if conditions = ready then do;
call execute( ' %include myRef /source2 ; ' ) ;
end ;
run ;[/pre] the point being that %include in open code will be executed unconditionally, so wrap call execute() around it to apply your conditions.

good luck
peterC
VD
Calcite | Level 5 VD
Calcite | Level 5
Very interesting solutions. Many thanks to both of you.
V

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 622 views
  • 0 likes
  • 4 in conversation