Hello,
I have some issues with the format of my macro variables.
I have a program where I have to determine around 15 macro variables by hand and I am trying to automate the process.
One of such variables would be:
%let ddebdet='01jan2016'd;
All of those 15 variables refer to different dates. I am trying to automate the process using the following code:
%let year=2018;
%let month=11;
data _null_;
call symputx('ddebdet', put(intnx('day',mdy(12,31,&year-3),0)+1,date9.));
run;
The idea is to adapt only two variables. Year and month, in this case and to generate 01jan2016 automatically.
This is the output that I'm getting:
2275 %put &ddebdet;
01JAN2016
2276
2277 %let ddebdet='01jan2016'd;
2278 %put &ddebdet;
'01jan2016'd
2279
2280
2281 %let year=2018;
2282 %let month=11;
2283
2284 data _null_;
2285 call symputx('ddebdet', put(intnx('day',mdy(12,31,&year-3),0)+1,date9.));
2286 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2287
2288
2289 %put &ddebdet;
01JAN2016
As you can see there is a difference between
2278 %put &ddebdet;
'01jan2016'd
and
2289 %put &ddebdet;
01JAN2016
It is quite problematic because the rest of my code doesn't work with the auto generated solution. For example this
data det;
set data
(where=(&ddebdet<=datepart(dtismaj)<=&dfindet and ctyp='350'));
run;
Returns the following error:
NOTE: Line generated by the macro variable "DDEBDET".
1230 01JAN2016
-------
22
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>,
=, >, >=, AND, EQ, GE, GT, LE, LT, NE, OR, ^=, |, ||, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
I don't really understand why I am having this issue.
Thanks in advance.