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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.