BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5

The following macro uses this month as a start date and goes back based on the number of months chosen to produce separate 30 day spreadsheets.  I want one report that combines February and March 2013 into one report (60 Day Analysis)  Go back 2 months instead of one month.

(ie 20130301_report.xls

20130301_report.xls

%MACRO FPD_IT (n=);

    DATA _NULL_;

    FirstDay=intnx('Month', TODAY(), &n, 'beginning');
    CALL SYMPUT('StartDate', FirstDay);
    CALL SYMPUT('StartDateMMMYY', PUT( FirstDay,EURDFMY5.));
    CALL SYMPUT('StartDateMonth', PUT( FirstDay,EURDFMN3.));
    CALL SYMPUT('StartDateYear', PUT( FirstDay,YEAR2.));
    RUN;

    %PUT &StartDate;
    %PUT &StartDateMMMYY;
    %PUT &StartDateMonth;
    %PUT &StartDateYear;


    DATA FPD;
     Merge mytable.table_&prev_bus_day.

     (Keep=
      LN_NO
      BO_BORR_FST_NM
      BO_BORR_MDL_NM
      BO_BORR_LAST_NM
      LN_NXT_PMT_DUE_DT
     );

    WHERE LN_NXT_PMT_DUE_DT EQ &StartDate.
     AND LN_FST_DUE_DT EQ &StartDate.

%FPD_IT (n=-1); /*pulls last month or February 2013 based on last month */
%FPD_IT (n=0); /*pulls March 2013, based on this month*/

1 REPLY 1
ArtC
Rhodochrosite | Level 12

We cannot see the end of your macro to see how you are making the report itself.  Most likely you want to create the WHERE in the DATA step so that it has all the appropriate dates.  You can also eliminate your DATA _NULL_ step.

%let lastddate = %sysfunc(intnx(Month, %sysfunc(TODAY()), &n));

%let startdate  = %sysfunc(intnx(Month, %sysfunc(TODAY()), %eval(&n-1)));

the WHERE becomes something like:

where &startdate le date le &lastdate;

But until we know more of what you need these are guesses.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 666 views
  • 0 likes
  • 2 in conversation