BookmarkSubscribeRSS Feed
Billybob73
Quartz | Level 8

 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.

4 REPLIES 4
LinusH
Tourmaline | Level 20

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...

Data never sleeps
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Why?  As:

%put %sysfunc(today(),date9.);

You only need to specify the format in the call...

Kurt_Bremser
Super User

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;

 

Tom
Super User Tom
Super User

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.

 

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 4115 views
  • 0 likes
  • 5 in conversation