Hi,
I'd like to convert the macro variable sasdate to date9. format, but I can't get this to work.
I get the message below and i don't know what this message means.
Anyone ?
Thanks very much !
21 %let sasdate=%sysfunc(intnx(year,%sysfunc(today()),0));
22 %let otherdate = %sysfunc(INPUTN(&sasdate., YYMMDD8.), date9.);
WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
Why don't you use the correct format in the first %sysfunc call?
Not sure why you need all this logic, why not
%let otherdate = 01Jan%substr(&sysdate9,6,4);
untested...
Why? As:
%put %sysfunc(today(),date9.);
You only need to specify the format in the call...
As soon as I see two or more %sysfunc's in a single line of code, I go data step:
data _null_;
sasdate = intnx('year',today(),0,'b');
call symput('otherdate',put(sasdate,date9.));
run;
Your first step is generating a raw date value. The number of days since 1/1/1960.
So the second step needs to use the PUTN() function to apply a format.
%let otherdate = %sysfunc(PUTN(&sasdate., date9.));
Or you could generate the value using YYMMDDn8. format to begin with.
%let sasdate=%sysfunc(intnx(year,%sysfunc(today()),0),yymmddn8);
Then your INPUTN() function call should work.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.