Hi @adventuresinsas
I realize it cannot handle a situation, where two consecutive records for the same ID has the same month, but in different years. They will be seen as the same month. This should be failsafe:
data want; set have;
if lag(ID)=ID and put(lag(Month),YYMM7.)=put(Month,YYMM7.) then count + 1;
else count=Var1;
run;
... View more