Here's one method:
%MACRO YEARDATES(SEED) ;
/* If no value passed, assume todays date */
%IF %STR(&SEED) eq %THEN %LET SEED = date() ;
data _null_ ;
do m = 1 to 12 ;
month_start = intnx('month',&SEED,m-13,'b') ;
month_end = intnx('month',&SEED,m-13,'e') ;
call symput(cats('MS',m),cats("'",put(month_start,date9.),"'d")) ;
call symput(cats('ME',m),cats("'",put(month_end ,date9.),"'d")) ;
end ;
run ;
options nosymbolgen nomprint ;
%DO M = 1 %TO 12 ;
%PUT %NRSTR(&MS)&M resolves to &&MS&M ;
%PUT %NRSTR(&ME)&M resolves to &&ME&M ;
%END ;
%MEND ;
/* Then call the macro like this.... (check log afterwards) */
%YEARDATES ; /* date() as seed */
%YEARDATES('07feb2013'd) ;
Then use the appropriate macro variables in your code, e.g.
data last12months ;
set mydata (where=(&MS1 <= date <= &ME12)) ;
run ;