difference between dosubl and call excecute

Accepted Solution Solved
Reply
Contributor
Posts: 50
Accepted Solution

difference between dosubl and call excecute


Hello SAS forum,

I am running code below here with the use of dosubl and call excute and getting same result.  I was wondering what is difference between them?

Thanks !!!

data _null_;

  x='SASHELP.CARS';

      rc=dosubl(cat('proc means data=',x,'; 'run'Smiley Wink)

run;

data _null_;

  x='SASHELP.CARS';

      call execute (cat('proc means data=',x,'; 'run'Smiley Wink)

run;


Accepted Solutions
Solution
‎05-22-2014 07:14 PM
Respected Advisor
Posts: 3,887

Re: difference between dosubl and call excecute

In my understanding CALL EXECUTE puts all the commands into a stack during iteration of the data step. Only after processing the last observation the commands in the stack will actually get executed. So call executes lets you pass parameters during data step iteration but won't return a result in the same iteration.

dosubl() on the other hand executes immediately during data step iteration so you can pass a parameter and get a result back. I assume though that such processing can be quite resource hungry so you want to use it only if really necessary.

View solution in original post


All Replies
Respected Advisor
Posts: 3,124

Re: difference between dosubl and call excecute

RTM. SAS(R) 9.4 Functions and CALL Routines: Reference, Second Edition

Run the following examples, are they the same now?

data _null_;

  rc=dosubl("data _null_; set sashelp.class;if _n_=1 then call symputx('working',name);stop;run;");

  name=symget('working');

put name=;

run;

data _null_;

  call execute ("data _null_; set sashelp.class;if _n_=1 then call symputx('notworking',name);stop;run;");

  name=symget('notworking');

put name=;

run;

Regards,

Haikuo

Contributor
Posts: 50

Re: difference between dosubl and call excecute

Hello Hai.kuo,

Thanks for the link.

Does  dosubl always work  where call execute works?  Since you mentioned call execute works only after next boundary step, it is more advantage to use dosubl where data step interface exits?

Regards,

Regular Contributor
Posts: 217

Re: difference between dosubl and call excecute

Hi,

http://support.sas.com/documentation/cdl/en/lefunctionsref/67239/HTML/default/viewer.htm#p09dcftd1xx...

I know that dosubl works in SAS 9.4.  and 9.3 TS Level 1M2.   I do not know if it works in earlier versions of SAS.

Respected Advisor
Posts: 3,124

Re: difference between dosubl and call excecute

"Does dosubl always work where call execute works?  "

I think so. Someone please correct me if I am wrong.  It is hard for me to envision a scenario that those Macros HAVE TO be executed AFTER the data step within which they are called.

Regards,

Haikuo

Contributor
Posts: 50

Re: difference between dosubl and call excecute

Hello Hai.kuo,

Here I found information about call execute:

CALL EXECURE  interacts with SAS Macro facility for immediate macro execution during the execution of DATA step.

Then I am assuing DOSUBL  execute immediately regardless of its arguments (text string) (does not have to wait to finish the current data step to execute). So no timing issue.

Thanks !!!

Solution
‎05-22-2014 07:14 PM
Respected Advisor
Posts: 3,887

Re: difference between dosubl and call excecute

In my understanding CALL EXECUTE puts all the commands into a stack during iteration of the data step. Only after processing the last observation the commands in the stack will actually get executed. So call executes lets you pass parameters during data step iteration but won't return a result in the same iteration.

dosubl() on the other hand executes immediately during data step iteration so you can pass a parameter and get a result back. I assume though that such processing can be quite resource hungry so you want to use it only if really necessary.

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 735 views
  • 3 likes
  • 4 in conversation