data preg1;
set preg;
by ID2 pregcycle;
if LAST.ID2;
run;
last.pregcycle picks the last record from each pregcycle. If you want last pregnancy, get the last per ID. If you have multiple records for the last pregnancy this won't work, it will keep only the last line.
... View more