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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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