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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.