Hi,
I'm trying to write some code that I need to run to backdate some reports. I want to compare data at one point to six months later.
I have created macro variables in the code like this: -
%let query_month = '01feb2018'd;
%let datalimit = %sysfunc(intnx(day,%sysfunc(today()),-1),date9.);
*Create macro variables;
data _null_;
month = intnx('month',&query_month.,0);
call symputx("file_month",put(intnx('month',month, 0), monyy5.),'G');
call symputx("start_file",put(intnx('month',month,-1,'e'), yymmddn8.),'G');
call symputx("start_date",put(intnx('month',month,-1,'e'), date9.),'G');
call symputx("end_file_1m",put(intnx('month',month,0,'e'), yymmddn8.),'G');
call symputx("end_date_1m",put(intnx('month',month,0,'e'), date9.),'G');
call symputx("end_file_6m",put(intnx('month',month,5,'e'), yymmddn8.),'G');
call symputx("end_date_6m",put(intnx('month',month,5,'e'), date9.),'G');
run;
The rest of my program is a macro program. Halfway into it, I then have some code that compares the &end_date_6m date with the &datalimit date and only want the next bit of code to run if the &end_date_6m is prior to &datalimit, as the data will not exist otherwise.
The log shows that the macro variables are being resolved as I would expect but SAS doesn't read one date as being earlier than the other
%if "&end_date_6m."d < "&datalimit."d %then %do;
SYMBOLGEN: Macro variable END_DATE_6M resolves to 31JUL2018
SYMBOLGEN: Macro variable DATALIMIT resolves to 04DEC2018
MLOGIC(ROLL_RATES): %IF condition "&end_date_6m."d < "&datalimit."d is FALSE
MLOGIC(ROLL_RATES): Ending execution.
I'm sure this must be something to do with the macro variables being resolved as character rather then the numeric values but could anyone advise me what I need to do to correct this?
As always, many thanks in advance.
Rob