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!
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.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.