hi ,
below is the small snippet :
%let year_month=202201; data try; temp=&year_month.-1; run;
I want my temp to be 202112 not 202200 . Can you please help me in give a quick solution.
Thanks in advance !
You want it be a DATE type variable or just simple NUMERIC type variable ?
%let year_month=202201; data try; temp=intnx('month',input("&year_month.01",yymmdd10.),-1); format temp yymmn6.; run;
Do you want it in a macro variable or a Data Step variable?
You want it be a DATE type variable or just simple NUMERIC type variable ?
%let year_month=202201; data try; temp=intnx('month',input("&year_month.01",yymmdd10.),-1); format temp yymmn6.; run;
I don't know if this is the best solution, but here's what I have.
%let yearmonth = %sysfunc(intnx(month, %sysfunc(inputn(202201, yymmn6.)),-1,e));
%put &yearmonth.;
82 %put &yearmonth.; 22645
@maguiremq wrote:
I don't know if this is the best solution, but here's what I have.
%let yearmonth = %sysfunc(intnx(month, %sysfunc(inputn(202201, yymmn6.)),-1,e)); %put &yearmonth.;
82 %put &yearmonth.; 22645
Close. If you want to generate the digit string in YYYYMM style then tell %SYSFUNC() to apply the YYMMN format to the value.
1725 %let yearmonth = %sysfunc(intnx(month, %sysfunc(inputn(202201, yymmn6.)),-1,e),yymmn6.); 1726 %put &=yearmonth; YEARMONTH=202112
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.