DATA Step, Macro, Functions and more

call execute use

Reply
Super Contributor
Posts: 271

call execute use

Hello,

 

Is CALL EXECUTE used  only in DATA  _null_ step to generate SAS code? I am curious if it is used elsewhere.

 

data _null_;
	set sashelp.class;
	call execute(cats('this is test','=',name));
run;

  

Super User
Posts: 5,516

Re: call execute use

Posted in reply to SAS_inquisitive

CALL EXECUTE can be used only in a DATA step.  It doesn't have to be a DATA _NULL_ step, but it is likely to be ... if the purpose of the DATA step is to generate the SAS statements that need to run next, it is unlikely that you want to save the data produced by the same step.

 

Experiment away.  You will find errors as you go, but you will get the hang of it.

 

Good luck.

Super Contributor
Posts: 441

Re: call execute use

Posted in reply to SAS_inquisitive

It's true that it is mostly used inside data _null_ steps but it's function is to generate SAS code so that's natural. If you want to learn more about Call Execute this paper is a good place to start http://www2.sas.com/proceedings/sugi22/CODERS/PAPER70.PDF - it's an oldie but still valid plus it was written by the great Ian Whitlock, a name many of us SAS veterans will recognise...

PROC Star
Posts: 283

Re: call execute use

Posted in reply to ChrisBrooks

@ChrisBrooks  Thank you for pointing to and sharing that article. It' amazing Ian's contributions are transcending generations. When I started my career as a SAS user 5 years ago, I was advised to basically read and understand every post of Ian's in SAS-L however I learned he wasn't posting anymore by then. Nevertheless, Art T gave me an exclusive link to all of Ian's posts and that's simply invaluable. So yeah, I really was intriuged to leave a comment as your suggestion to OP brought me a smile. Smiley Happy

Super Contributor
Posts: 441

Re: call execute use

Posted in reply to novinosrin

@novinosrin I had the great good fortune to meet Ian Whitlock once. I was introduced to him and a number of other SAS luminaries at SUGI 30 in Philadelphia way back in 2005 during the course of a very convivial lunch. Like so many other SAS geniuses (genii?) he was a very quiet, modest man and ever since whenever I've mentored novice SAS programmers I've always told them "If you want to understand data step programming read everything you can find by Ian Whitlock"!

Super Contributor
Posts: 271

Re: call execute use

Posted in reply to ChrisBrooks

Thank you all. @novinosrin Can you share that link?

Super Contributor
Posts: 441

Re: call execute use

Posted in reply to SAS_inquisitive

@SAS_inquisitive I don't have that but if you click this link http://www.lexjansen.com/search/searchresults.php?q=ian%20whitlock you should find most, if not all, the papers he published over the years.

PROC Star
Posts: 7,491

Re: call execute use

Posted in reply to SAS_inquisitive

@SAS_inquisitive: It's not a link but, rather, an Excel workbook that contains links to all of Ian's SAS-L posts over the years. I'd publish it, but Ian has never given me permission to do so, so I haven't. However, I have no problem sharing it as long as the recipient agrees not to make it publically available.

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 19,861

Re: call execute use

Posted in reply to SAS_inquisitive

If the paper doesn't cover it, also look into DOSUBL.

Super Contributor
Posts: 441

Re: call execute use

Good point @Reeza - the paper was written long before DOSUBL existed. There is a subtle difference between the two which was explained here https://communities.sas.com/t5/General-SAS-Programming/difference-between-dosubl-and-call-excecute/t...

Super User
Posts: 10,044

Re: call execute use

Posted in reply to SAS_inquisitive
CALL EXECUTE() also can be used under SAS/IML.

http://blogs.sas.com/content/iml/2015/01/14/global-statements-loops.html


Ask a Question
Discussion stats
  • 10 replies
  • 351 views
  • 8 likes
  • 7 in conversation