BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mhoward2
Obsidian | Level 7

So I have this code that defines a variable:

%LET Inc_Start = &&&Inc_Start_YYYY..&Inc_Start_MM;

Whenever I use this, the variable works exactly as it should and I get the exact YYYYMM. However I want to be able to actually get YYYYMMDD where the DD is just the last day of the month. I currently am trying something like this:

%LET Inc_Start = %sysfunc(intnx(month, &&&Inc_Start_YYYY..&Inc_Start_MM, 0, e));

But this gives me the following log output:

87         %PUT &Inc_Start;
SYMBOLGEN:  Macro variable INC_START resolves to 202130

You can see that is YYYYDD and it skips the MM inbetween them! Any ideas? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

So you first need to convert the YYYYMM to a SAS date before you can use it in the INTNX function.

%LET Inc_Start = &&&Inc_Start_YYYY..&Inc_Start_MM;
%let inc_start = %sysfunc(intnx(month,%sysfunc(inputn(&inc_start.,yymmn6.)),0,e),yymmddn8.);

Untested, posted from my tablet.

For tested code, we would need to know the contents of the macro variables you use.

 

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

So you first need to convert the YYYYMM to a SAS date before you can use it in the INTNX function.

%LET Inc_Start = &&&Inc_Start_YYYY..&Inc_Start_MM;
%let inc_start = %sysfunc(intnx(month,%sysfunc(inputn(&inc_start.,yymmn6.)),0,e),yymmddn8.);

Untested, posted from my tablet.

For tested code, we would need to know the contents of the macro variables you use.

 

mhoward2
Obsidian | Level 7
Thank you very much! I greatly appreciate the help!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 2 replies
  • 3878 views
  • 0 likes
  • 2 in conversation