BookmarkSubscribeRSS Feed
Danglytics
Calcite | Level 5

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!

1 REPLY 1
Reeza
Super User

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);

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1655 views
  • 0 likes
  • 2 in conversation