As you recall, there are some missing values in dataset ‘test3.’ Since we need to know which group pertains to which sex, we need to fill in the empty cells:
data test4;
set test3;
by id;
RETAIN filledName filledSex filledDOB;
IF NOT MISSING(Name) THEN
filledName = Name; Name = filledName;
IF NOT MISSING(Sex) THEN
filledSex=Sex; Sex=filledSex;
IF NOT MISSING(DOB) THEN
filledDOB = DOB; DOB=filledDOB;
DROP filledName filledSex filledDOB;
RUN;