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-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
  • 2 replies
  • 2455 views
  • 0 likes
  • 2 in conversation