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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.