Are you asking for this
data _null_;
call symputx('Fetch_M', put(intnx ('month',today(),-2),yymmn6.) );
run;
%put Fetch_M = &Fetch_M.;
%let year=%substr( &Fetch_M.,1,4);
%let subtracted_year=%eval(&year-2);
%put &=subtracted_year;
Current year from what?
today()?
todatetime()?
/*Año y mes*/
data _null_;
call symputx('Fetch_M', put(intnx ('month',today(),-2),yymmn6.) );
run;
%put Fetch_M = &Fetch_M.;
to need current year in format "2019"
Are you asking
data _null_;
call symputx('Fetch_M', put(intnx ('month',today(),-2),yymmn6.) );
run;
%put Fetch_M = &Fetch_M.;
%put year=%substr( &Fetch_M.,1,4);
Log
5 %put Fetch_M = &Fetch_M.;
Fetch_M = 201902
6 %put year=%substr( &Fetch_M.,1,4);
year=2019
Or in %let
%let year=%substr( &Fetch_M.,1,4);
%put &=year;
great!!!
%let year=%substr( &Fetch_M.,1,4);
%put &=year;
Are you asking for this
data _null_;
call symputx('Fetch_M', put(intnx ('month',today(),-2),yymmn6.) );
run;
%put Fetch_M = &Fetch_M.;
%let year=%substr( &Fetch_M.,1,4);
%let subtracted_year=%eval(&year-2);
%put &=subtracted_year;
%let currentYear = %sysfunc(today(), year4.);
%put ¤tYear.;
TODAY() returns todays date.
%SYSFUNC() takes two parameter, a SAS function (TODAY()) and the format used. YEAR4 converts it to the year.
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.