DATA Step, Macro, Functions and more

Data Step Events

Reply
N/A
Posts: 1

Data Step Events

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

Frequent Contributor
Posts: 106

Re: Data Step Events

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

Ask a Question
Discussion stats
  • 1 reply
  • 140 views
  • 0 likes
  • 2 in conversation