Rick,
Here is another way to get first.group and last.group as long as the table is sorted by group.

data have;
input obs x1 group;
cards;
1 4.3 1
2 5.6 1
3 1.9 2
4 1.6 2
5 5.2 2
6 1.6 3
7 3.2 3
8 5.1 4
9 3.4 4
10 5.4 4
11 6.3 5
;
run;

proc iml;
use have;
read all var _num_ into x[c=vname];
read all var {group};
close;
lag=lag(group,1);
prev=group[2:nrow(x)]//{.};
want=x[loc(group^=lag | group^=prev),];
print x,want[c=vname];
quit;