/*Año y mes Atras*/
data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),-40),yymmn6.) );
run;
%put Fetch_FIN = &Fetch_FIN.;
@yesidgranadosv wrote:
I have this code which gives me back the date of 201601/*Año y mes Atras*/
data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),-40),yymmn6.) );
run;%put Fetch_FIN = &Fetch_FIN.;
Could help me improve the code
Improve in what way??
and other than this I need a condition with the every time it is a new year is added a year more to the result
I mean that when it is 2020 the result of Fetch_FIN is 2017
Exactly you are right... The idea is that it is a simpler code and the program would run daily and would not apply for what I want... I just wanted to express the result I want to get...
Not how to express it in a new code much more efficient for what I want
Honestly, I don't understand the issue.
You use the word "Simpler" but the code is 4 lines, it's hard to get simpler than that.
You use the word "efficient" but the code runs in fractions of a second, it's hard to get more efficient than that.
Unfortunately your question is still unclear.
Please show:
An example of what you have (variable, data set, code)
What you want as the output?
What isn't working - for example include the log or output that shows what you get.
@yesidgranadosv wrote:
Exactly you are right... The idea is that it is a simpler code and the program would run daily and would not apply for what I want... I just wanted to express the result I want to get...
Not how to express it in a new code much more efficient for what I want
@yesidgranadosv wrote:
I have this code which gives me back the date of 201601/*Año y mes Atras*/
data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),-40),yymmn6.) );
run;%put Fetch_FIN = &Fetch_FIN.;
Could help me improve the code and other than this I need a condition with the every time it is a new year is added a year more to the resultI mean that when it is 2020 the result of Fetch_FIN is 2017
If you are concerned about a specific interval of years then do not rely on 'month'. If you want to get the first day of the year then use an alignment value of 'B'. Example to get the beginning of the year that is 3 years prior. Note this will return the same value for ANY date in 2020. If that is not the desired output then you need to provide better examples of your input value(s) and the expected output.
data _null_; call symputx('Fetch_FIN', put(intnx ('year','01MAR2020'd,-3,'B'),yymmn6.) ); run; %put Fetch_FIN = &Fetch_FIN.;
1 %let Fetch_FIN =%sysfunc(intnx(month,%sysfunc(today()),-40),yymmn6);
2 %put NOTE: &Fetch_fin;
NOTE: 201601
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.