DATA Step, Macro, Functions and more

Combine Into One Report Using Macro FPD_It(n=)

Reply
Contributor
Posts: 59

Combine Into One Report Using Macro FPD_It(n=)

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*/

Valued Guide
Posts: 632

Re: Combine Into One Report Using Macro FPD_It(n=)

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.

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