Data summary;
infile 'D:\SASdatafile\survey.txt' dlm=',';
input Household_ID: $10. Type $ no_of_members @;
no_of_males=0;
no_of_females=0;
no_of_employed=0;
household_income=0;
do index=1 to no_of_members;
input Household_Mem_No H_indicator$ DOB: date9. Gender $ M_Status $ E_level E_status $ M_income @;
if Gender ='M' then no_of_males +1;
else no_of_females +1;
if E_status = 'FT' or E_status = 'PT' then no_of_employed+1;
if H_indicator='Y' then Age_Householder=yrdif(dob,'30dec2008'd,'Actual');
Age_Householder=round(Age_Householder,0.5);
household_income +M_income;
end;
average_income=Household_income/no_of_members;
average_income=round(average_income,0.01);
keep Household_ID type no_of_males no_of_females no_of_employed Age_Householder average_income ;
run; The data of survey.txt is as follows: 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
... View more