Data household (drop=HorP_indicator) ; Infile datalines dsd ; retain Household_identity Type No_of_members; input HorP_indicator :$10. @ ; if length(HorP_indicator )>1 then do; input @1 Household_identity :$10. @12 Type $ No_of_members; *Member_no H_Indicator $ DOB :date9. Gender $ M_status $ Edu_level E_Status $ M_Income; end; else do; input @1 Member_no H_Indicator $ DOB :date9. Gender $ M_status $ Edu_level E_Status $ M_Income ; output; end; format DOB date9.;
datalines; A123456789,A,3 1,Y,15Feb1960,M,M,3,FT,55000 2,N,3Jun1965,F,M,3,UE,0 3,N,24Jan1988,M,S,2,NA,3000 A135790234,B,1 1,Y,19Oct1944,F,D,0,NA,3000 B234523456,A,2 1,Y,30Jun1978,F,M,1,PT,4000 2,N,21May1975,M,M,2,FT,30000 proc print; run; /* summary */; data want; set household; by household_identity; if first.household_identity then age+intck('year',dob,today())-12; if e_status in ('FT','PT') then employed+1; income+M_income; if gender='M' then males+1; else females+1; if last.household_identity then do; income=income/no_of_members; output; employed=0; income=0; males=0; females=0; age=0; end; keep type males females age employed income household_identity; proc print label split='*'; id household_identity type males females employed age income; label males='number of* male members' females='number of*female members' age='age of *householder' income='average*household*income'; run;
Jim
... View more