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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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