I have a block of code which extracts customers who had made a transfer in the last month. This macro is currently monthly and runs once a month.
Now, I want to run this code on every Monday for the last 4 months.
How can I use a macro to achieve this and convert this exercise from monthly to weekly so that this macro runs on every Monday and we get the list of customers who made a transfer in last 7 days?
%LET Mon_ST = 202111;
%LET Mon_EN = 202201;
Option obs = Max;
%macro copy_data();
%DO Mnth = &Mon_ST. %TO &Mon_EN. ;
%IF %SUBSTR(&Mnth.,5,2) = 13 %THEN %LET Mnth = %EVAL(%SUBSTR(&Mnth.,1,4)+1)01;
%let YYYYMMDD = %SYSFUNC(INTNX(Month,"%SYSFUNC(MDY(%SUBSTR(&Mnth.,5,2),01,%SUBSTR(&Mnth.,1,4)),DATE9.)"D,0,E),YYMMddN8.);
%Let Track_strt=%SYSFUNC(INTNX(Day,"%SYSFUNC(MDY(%SUBSTR(&YYYYMMDD.,5,2),%SUBSTR(&YYYYMMDD.,7,2),%SUBSTR(&YYYYMMDD.,1,4)),DATE9.)"D,-30,B),YYMMDDN8.);
%Let Track_endt=%SYSFUNC(INTNX(Day,"%SYSFUNC(MDY(%SUBSTR(&YYYYMMDD.,5,2),%SUBSTR(&YYYYMMDD.,7,2),%SUBSTR(&YYYYMMDD.,1,4)),DATE9.)"D,0,E),YYMMDDN8.);
%Put &Track_endt. &Track_strt.;
/***** Block of Code extracting transfer history information in last 1 month *****/
%end;
%mend;
%copy_data();
... View more