Desktop productivity for business analysts and programmers

Macro to automate process flow run?

Reply
Contributor
Posts: 66

Macro to automate process flow run?

Hi,

I have a process flow with a Setup program that contains my month end time periods:

***************************************************************************************************;

* SETUP

/***************************************************************************************************;

%LET CUTOFF_DATE='31OCT2010'D;

%LET TIMESTAMP=2010OCT31;

***************************************************************************************************;

%LET CUTOFF_DATE='30NOV2010'D;

%LET TIMESTAMP=2010NOV30;

***************************************************************************************************;

%LET CUTOFF_DATE='31DEC2010'D;

%LET TIMESTAMP=2010DEC31;

etc..

Currently i am having to comment out the code and run the entire process flow based on one time period, then changing it and pressing run process flow again for the next time period.

it is very manual, and not at all efficient, I was wondering if there is a way for me to automate this? in a macro? part of EG?

thanks for your help!

Grand Advisor
Posts: 17,294

Macro to automate process flow run?

I'd recommend a macro.

Here's the start of one that shows you how to loop through your date variables. You may need to play with the formats to get what you need exactly and this isn't the most efficient way but thought it might be highly understandable if you have no idea of where to start.

*Macro to loop through the dates;

%macro run_reports(start_interval, num_intervals);

   

%do i=0 %to %eval(&num_intervals-1);

    *set macro variables;

    data _null_;

        report_date=intnx('month', "&start_interval"d, &i., 'end');

        call symput('report_date', put(report_date, date9.)); *formatted date, 31Jan2011;

        *call symput('report_date', report_date); *SAS date as number;

    run;

    %put &report_date.;

    ****************

    Put the code you need to run here, either as straight sas code or as another macro as a %include

    *****************;

%end;*End do macro do loop;

%mend run_reports; *End macro code;

%run_reports(31dec2010, 3);

%run_reports(31dec2011, 3);

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