proc sort data=test;
by name year qtr;
run;
proc sql;
create table allclass1 as
select distinct name, year
from test;
quit;
data allclass2;
set allclass1(keep=name year);
do qtr=1 to 4;
output;
end;
run;
proc sort data=allclass2;
by name year qtr;
run;
data wanted;
merge test allclass2;
by name year qtr;
length _ins _sex $40;
retain _ins _sex;
if first.name then do;_ins=' ';_sex=' ';end;
if ^missing(institution) then do;
_ins=institution;
_sex=sex;
end;
else do;
institution=_ins;
sex=_sex;
end;
if institution='' then delete;
drop _ins _sex;
run;