I would try it this way:
proc sort data=have;
by id year month;
run;
data want;
set have;
by id;
current_date = mdy(month, 1, year);
prior_date = lag(current_date);
if prior_date ne intnx('month', current_date, -1) then changes + 1;
if first.id then changes=0;
if last.id;
run;
This assumes that your goal is as stated, to count the changes (not to identify the year/month). The count actually omits anything occurring after the final observation (in this case the 1/16 change). But you could always add 1 at the end to account for that.
... View more