Again why do you need to? It is very simple to assign a grouping variable:
data want;
set have; array group{12} 1;
do i=1 to 12; if month(date) >= i then group{i}=1; end; run;
You then have a set of group variables which you can perform procedures by, for example to run a proc means on all data from april:
proc means data=want;
var result;
where group{4}=1;
output out=april n=n;
run;
You could of course put the grouping into one group, then do it across all by groups very simply.
This code minimises the read/writes - i.e. saving processor time, and saving disk space. Minimises the coding needed, all inbuilt simple Base SAS, and minimises upkeep.
Anyways, am sure you will go ahead anyways, so here is my example - note how I put some test data in a datastep:
data have;
date='11JAN2019'd; result=12; output;
date='12FEB2019'd; result=12; output;
run;
data have;
set have;
period=month(date);
run;
data _null_;
do i=1 to 12;
call execute(cats('data period_',put(i,best.),'; set have; where month(date) >= ',put(i,best.),'; run;'));
end;
run;
This will create 12 datasets, each where month of date is greater than current iteration, so 2 records in period1, 1 in period2, 0 in all others. However do bear in mind that is 12 read/writes, + 12 header block storage, this code will run slower than doing the by group processing.
... View more