How to use a macro variable to be lagged like a date in SAS -
i'm using sas. have more datesets, 1 per month , have compute variations, means etc. considering more datasets (months) @ same step of macro because example var1 have 1 value in dataset of january (month x) , 1 value in dataset of february (month x+1).
the datasets named in way: xxxxxx_yearmonth (for example yearmonth=201512 december 2015)
so have create macro variable called yearmonth can lagged more months can recall them.
i thought recall datasets macro variable yearmonth , do: yearmonth - 1 ... yearmonth - 2 ... yearmonth - n. there problem because if january 2015 yearmonth=201501 , yearmonth-1=201500 , not 201412. fact sas doesn't recognize yearmonth date treat simple number.
how can manage problem?
thanks in advance.
convert string date , use intnx() function.
%let current=201501; %let prev=%sysfunc(intnx(month,%sysfunc(inputn(¤t.01,yymmdd8)),-1),yymmn6); %put &=prev;
Comments
Post a Comment