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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 480 views
  • 0 likes
  • 2 in conversation