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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.