BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

User define macro parameter with %let in format of YYMM.

I know how to create a new macro parameter that is sas date(numeric number that represent number of days since 1.1.1960)

 

My question:

I want to create a SAS date (number of days since 1.1.1960) of 2 months before &start.

However it is not working and I receive an error and also the value that I get is null.

WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.

 

%let start=1909;/*YYMM*/
%put &start;
%let date_start=%sysfunc(inputn(&start,yymmn4.));
%put &date_start;

%let t=%sysfunc(inputn(intnx('month',&start,-2),yymmn4.));
%put &t;
1 REPLY 1
Reeza
Super User

1. %SYSFUNC() is needed on every function (INPUTN and INTNX)

2. But, %SYSFUNC() also has a second parameter that acts as the format so you don't need the INPUTN actually. 

3. You were referencing start instead of date_start in the third calculation, but I think you really wanted the date_start macro variable that's a SAS date instead.

 

Or nest all together of course.

 

%let start=1909;/*YYMM*/
%put &start;

%let date_start=%sysfunc(inputn(&start,yymmn4.));
%put &date_start;

%let t=%sysfunc(intnx(month, &date_start, -2, s), yymmn4.);
%put &t;

@Ronein wrote:

Hello

User define macro parameter with %let in format of YYMM.

I know how to create a new macro parameter that is sas date(numeric number that represent number of days since 1.1.1960)

 

My question:

I want to create a SAS date (number of days since 1.1.1960) of 2 months before &start.

However it is not working and I receive an error and also the value that I get is null.

WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.

 

%let start=1909;/*YYMM*/
%put &start;
%let date_start=%sysfunc(inputn(&start,yymmn4.));
%put &date_start;

%let t=%sysfunc(inputn(intnx('month',&start,-2),yymmn4.));
%put &t;

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 598 views
  • 0 likes
  • 2 in conversation