I have the following code:
/*Importação para a memória da base de Janeiro*/;
Data D201901 (keep=U);
Set D201901;
Run;
Data E201901s (keep=U);
Set E201901s;
Run;
Instead of 201901 I want n-24, i.e., the 24th previous month.
I want to create a monthly routine program.
Can you help me writing the proper code?
Would you like to hardcode the "specific month" like this?
%let basemon=202101;
%let mon=%sysfunc(intnx(month,%sysfunc(inputn(&basemon,yymmn6.)),-24),yymmn.);
This yields 201901.
Hello @ramgouveia,
@ramgouveia wrote:Instead of 201901 I want n-24, i.e., the 24th previous month.
Do you mean "today minus 24 months"? If so, you can (at the beginning of your program) define a macro variable, say MON, in a way that dynamically creates the YYYYMM expression by subtracting 24 months from the date when the program runs:
%let mon=%sysfunc(intnx(month,%sysfunc(today()),-24),yymmn.);
Submitted today, this yields 201904.
Then replace all occurrences of 201901 in your code by
&mon.
For example, write
EFAT_&mon.s
instead of EFAT_201901s.
Thank you @FreelanceReinh
But here:
%let mon=%sysfunc(intnx(month,%sysfunc(today()),-24),yymmn.);
Instead of today function how can I define a specific month?
Would you like to hardcode the "specific month" like this?
%let basemon=202101;
%let mon=%sysfunc(intnx(month,%sysfunc(inputn(&basemon,yymmn6.)),-24),yymmn.);
This yields 201901.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: