Staff are in two wage category “H” and “S” . Sort the table by wage category and wage rate. Firstrate will equal to 1 if it is the first record in the wagecategory, and the lastrate will equal to 1 if it is the last record in the wagecategory.
proc sort data=sasuser.staff out =sortstaff; by wagecategory wagerate; run; data sortstaff; set sortstaff; by wagecategory; firstrate = first.wagecategory; lastrate = last.wagecategory; run;