I've been looking for a way to create a variable that can let me run a proc sql select a table for a specific 10 months looking back. the parameter should have the format of YYYYMM.
so e.g. &YYYYMM = 202102 this will allow me to run the proc sql select data from 202005 until 202101.
Any help would be so very much appreciated!! Thanks very much!!
So you want to make a dataset with one observation per date? Do you want to make a DATE variable or CHARACTER variable? Or perhaps a numeric variable with those digit strings as numbers instead of actual date values?
%let end_month=202102;
data want;
do offset=-9 to -1 ;
date = intnx('month',input("&end_month",yymmn6.),offset);
string=put(date,yymmn6.);
number=input(string,6.);
output;
end;
format date yymmdd10.;
run;
Result: