Good Day All,
first simply what i am looking for is a way to execute a static peice of code after every data step / proc step completes.
I do not want to do this
DATA D1;
/*Code*/
RUN;
%StaticMacro;
DATA D2;
/*Code*/
RUN;
%StaticMacro;
Rather i want to find a way to affect the processing of a data step like you would with application programming, using events.
so i need to find the event that is called just after the data step has finished, a common coded example is:
Sub ABC_Finished()
End Sub
is there such a way to affect processing?
Kind Regards,
Mahesh
Hi Mahesh,
Is there such a way? Not that I knew. (As if that meant a lot 😉 )
However you could create a macro replacement to the RUN and QUIT statement respectively.
Somewhat like this:
%macro static_macro ( called_after = NONE ) ;
%put &sysmacroname called after &called_after ;
%mend static_macro ;
%macro rq (rq_cmd) ;
%local _sp ;
%let _sp = &sysprocname ;
&rq_cmd ;
%static_macro ( called_after = &_sp ) ;
%mend rq ;
data _null _ ;
put 'Note: Message from datastep.' ;
%rq ( run ) ;
proc sql noprint ;
select max(age) as max_age from sashelp.class ;
%rq ( quit ) ;
So not an EVENT like solution, much rather a workaround.
BTW: you could get fancier by using automatic macro variable &SYSPROCNAME but I think coding RUN/QUIT as an argument of the RQ macro enhances readability.
Kind regards
Robert
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.