You hadn't stated what defines the measurement year, so I had guess it was the most recent date for a given memberID, and continued for one year prior to that date.
If that was correct, then the following would account for your latest criterion:
proc sort data=have;
by MemberID descending ServiceDate;
run;
data want (drop=year_start year_boundary);
set have;
by MemberID descending ServiceDate;
retain year_start year_boundary;
if first.MemberID then do;
Year='Measurement Year';
year_start=intnx('year',ServiceDate,-1,'S');
year_boundary=intnx('year',ServiceDate,-2,'S');
end;
else if ServiceDate gt year_start then year='Measurement Year';
else if ServiceDate gt year_boundary then year='Prior Year';
else call missing(year);
run;
Art, CEO, AnalystFinder.com
... View more