You only have 2 IDs in your output, is that a mistake? I don't know why you are dropping 10. Here is a solution but it has three IDs: data have; infile cards dsd; input MOTHER_ID BIRTH_YR birth_num; cards; 5,2009,1 7,2004,1 10,2005,1 10,2008,2 10,2010,3 12,2006,1 12,2008,2 14,2004,1 14,2006,2 14,2008,3 ; run; data want; do until (last.mother_id); set have; by mother_id; if birth_num = 2 then _flag = 1; end; do until (last.mother_id); set have; by mother_id; if _flag = 1 then output; end; where birth_num < 3; drop _:; run;
... View more