@PierreYvesILY wrote:
hello Paige,
I'm a SAS new user, and I don't know much about macrocode.
%superq and %qsysfunc are functions I don't know at all.
Finally, what I Need is :
1. a macro Monat where the month as a 'number' is saved : for instance: January =1 and December = 12.
The &Monat. has to be the month BEFORE the &Auswertungstag.
therefore: if &Auswertungstag. = '01JAN2021'D => &Monat. = 12
So, this is not the original problem. It really helps if you state the actual problem in your original message, rather than changing it after we have worked on your problem.
Try this:
%let Auswertungstag = %sysevalf('01JAN2020'd); *Bei Bedarf: Datum vorgeben;
%let previous_month = %sysfunc(intnx(month,&Auswertungstag,-1,b));
%let year=%sysfunc(year(&previous_month));
%let month=%sysfunc(month(&previous_month));
%put &=Auswertungstag;
%put &=previous_month;
%put &=year;
%put &=month;
An important point here, whenever you deal with calendar dates is to represent the data as a valid SAS date, which means the number of days since January 1, 1960. So, January 1, 2020 is represented as 21915. Then you can find the previous month using the INTNX function, so you don't have to write your own code that knows what month comes before any specified month, SAS has already created a function to do this.
... View more