Appendix 5: Income and Assets Variable Creation

Return to Table of Contents


Household Income

Variables Created:

Variables Used

      These variables are listed in a separate file (due to the length of the list).

This program creates the gross household income variables. The gross household income variable coded as groshhIY includes total annual cash receipts before taxes from all sources. The program then creates a ratio comparing the household's total income to federal poverty guidelines based on the number of household residents and the number of members under age 18.

Researchers should note that, like many income and asset variables in the data set, these two variables are topcoded to protect respondent privacy.  More information about topcoding is available in the NLSY97 User's Guide.


*****************SECTION 1: GROSS HOUSEHOLD INCOME*****************

*************************************;
**income from non-farm employment, nfarmY**;
*************************************;

nfarmY=-4; /*assign a default value to nfarmY*/

if YI_1400=1 or ((YI_1400 in (-1,-2,-3)) and (YI_1600 eq 1)) then do;
flag_nfarmY=1; /* 1 means R has non-farm income*/
/* 2 means R has non-farm income, however the amount is an estimate.*/

if YI_1700 >= 0 then nfarmY=YI_1700;
else if YI_1700 in (-1,-2,-3) then do; /*R does not give the exact number.*/
if YI_1800 eq 1 then do; /*begin the estimating */
flag_nfarmY=2;
nfarmY=2500;
end;
else if YI_1800 eq 2 then do;
flag_nfarmY=2;
nfarmY=7500;
end;
else if YI_1800 eq 3 then do;
flag_nfarmY=2;
nfarmY=17500;
end;

else if YI_1800=4 then do;
nfarmY=37500;
flag_nfarmY=2;
end;
else if YI_1800=5 then do;
nfarmY=75000;
flag_nfarmY=2;
end;
else if YI_1800=6 then do;
nfarmY=175000;
flag_nfarmY=2;
end;
else if YI_1800=7 then do;
nfarmY=250001;
flag_nfarmY=2;
end;
end;
end;

if YI_1600=-1 or YI_1800=-1 then nfarmY=-1;/*R refuse to answer */
else if YI_1600=-2 or YI_1800=-2 then nfarmY=-2;/*R don't know */
else if YI_1600=-3 or YI_1800=-3 then nfarmY=-3;/*R invalid skip */

*****this is the end of non-farm income*****;

*****************************************************;
** Income from farm and self-employment of respondent - (farmY)**;
*****************************************************;

farmY=-4; /*assign a default value to farmY */

if YI_2000=1 then do;
flag_farmY=1; /*R has farm income */
if YI_2100 >= 0 then farmY=YI_2100;/*get the amount of farm income */
else if YI_2100 in (-1,-2,-3) then do;/*R don't give the exact number */

if YI_2200=1 then do; /*begin to estimate the farm income */
farmY=-2;

end;
else if YI_2200=2 then do;
farmY=2500;
flag_farmY=2;
end;
else if YI_2200=3 then do;
farmY=7500;
flag_farmY=2;
end;
else if YI_2200=4 then do;
farmY=17500;
flag_farmY=2;
end;
else if YI_2200=5 then do;
farmY=37500;
flag_farmY=2;
end;
else if YI_2200=6 then do;
farmY=75000;
flag_farmY=2;
end;
else if YI_2200=7 then do;
farmY=175000;
flag_farmY=2;
end;
else if YI_2200=8 then do;
farmY=250001;
flag_farmY=2;
end;
end;
end;
if YI_2000=-1 or YI_2200=-1 then farmY=-1;
else if YI_2000=-2 or YI_2200=-2 then farmY=-2;
else if YI_2000=-3 or YI_2200=-3 then farmY=-3;

*****this is the end of farm income.*****;


******************************;
**Worker's Compensation,wcompY**;
******************************;

wcompY=-4;
if YI_2250=1 then do;
flag_wcompY=1;
if YI_2260>=0 then wcompY=YI_2260;
else if YI_2260 in (-1,-2,-3) then do;
*if 2<=YI_2270<=8 then flag_wcompY=2;
if YI_2270=1 then do;
flag_wcompY=2;
wcompY=500; /*then what is flag_wcomY?*/
end;
else if YI_2270=2 then do;
wcompY=1750;
flag_wcompY=2;
end;
else if YI_2270=3 then do;
wcompY=3750;
flag_wcompY=2;
end;
else if YI_2270=4 then do;
wcompY=7500;
flag_wcompY=2;
end;
else if YI_2270=5 then do;
wcompY=17500;
flag_wcompY=2;
end;
else if YI_2270=6 then do;
wcompY=37500;
flag_wcompY=2;
end;
else if YI_2270=7 then do;
wcompY=50001;
flag_wcompY=2;
end;

end;
end;
if YI_2250=-1 or YI_2270=-1 then wcompY=-1; /*R refuse to answer. */
else if YI_2250=-2 or YI_2270=-2 then wcompY=-2; /*R don't know. */
else if YI_2250=-3 or YI_2270=-3 then wcompY=-3; /*invalid skip */

*****this is the end of worker's compensation.*****;



*************************************************************;
**Income from non-farm employment of respondent's spouse/partner - nfarmP**;
*************************************************************;
nfarmP=-4;
if YI_2300=1 & (YI_2400=1 or (YI_2400=-1 & YI_2500=1)) then do;
flag_nfarmP=1;
if YI_2600>=0 then nfarmP=YI_2600;
else if YI_2600 in (-1,-2,-3) then do;
if YI_2700=1 then do;
nfarmP=2500;
flag_nfarmP=2;
end;
else if YI_2700=2 then do;
nfarmP=7500;
flag_nfarmP=2;
end;
else if YI_2700=3 then do;
nfarmP=17500;
flag_nfarmP=2;
end;
else if YI_2700=4 then do;
nfarmP=37500;
flag_nfarmP=2;
end;
else if YI_2700=5 then do;
nfarmP=75000;
flag_nfarmP=2;
end;
else if YI_2700=6 then do;
nfarmP=175000;
flag_nfarmP=2;
end;
else if YI_2700=7 then do;
nfarmP=250001;
flag_nfarmP=2;
end;
end;
end;
if YI_2300=-1 or YI_2500=-1 or YI_2700=-1 then nfarmP=-1;
else if YI_2300=-2 or YI_2400=-2 or YI_2500=-2 or YI_2700=-2 then nfarmP=-2;
else if YI_2300=-3 or YI_2400=-3 or YI_2500=-3 or YI_2700=-3 then nfarmP=-3;

*****this is the end of non-farm income from partner/spouse.*****;


********************************************************;
**Income from farm and self-employment of R's spouse/partner - farmP**;
********************************************************;

farmP=-4;
if YI_2300=1 & YI_2900=1 then do;
flag_farmP=1;
if YI_3000>=0 then farmP=YI_3000;
else if YI_3000 in (-1,-2,-3) then do;
*if 2<=YI_3100<=8 then flag_farmP=2;
if YI_3100=1 then farmP=-2;
else if YI_3100=2 then do;
farmP=2500;
flag_farmP=2;
end;
else if YI_3100=3 then do;
farmP=7500;
flag_farmP=2;
end;
else if YI_3100=4 then do;
farmP=17500;
flag_farmP=2;
end;
else if YI_3100=5 then do;
farmP=37500;
flag_farmP=2;
end;
else if YI_3100=6 then do;
farmP=75000;
flag_farmP=2;
end;
else if YI_3100=7 then do;
farmP=175000;
flag_farmP=2;
end;
else if YI_3100=8 then do;
farmP=250001;
flag_farmP=2;
end;
end;
end;
if YI_2300=-1 or YI_2900=-1 or YI_3100=-1 then farmP=-1;
else if YI_2300=-2 or YI_2900=-2 or YI_3100=-2 then farmP=-2;
else if YI_2300=-3 or YI_2900=-3 or YI_3100=-3 then farmP=-3;

*****this is the end of farm income of R's partner/spouse*****;


*************************************************;
** worker's compensation from R's partner/spouse - wcompP**;
*************************************************;

wcompP=-4;
if YI_2300=1 & YI_3150=1 then do;
flag_wcompP=1;
if YI_3160>=0 then wcompP=YI_3160;
else if YI_3160 in (-1,-2,-3) then do;
*if 1<=YI_3170<=7 then flag_wcompP=2;
if YI_3170=1 then do;
wcompP=500;
flag_wcompP=2;
end;
else if YI_3170=2 then do;
wcompP=1250;
flag_wcompP=2;
end;
else if YI_3170=3 then do;
wcompP=3750;
flag_wcompP=2;
end;
else if YI_3170=4 then do;
wcompP=7500;
flag_wcompP=2;
end;
else if YI_3170=5 then do;
wcompP=17500;
flag_wcompP=2;
end;
else if YI_3170=6 then do;
wcompP=37500;
flag_wcompP=2;
end;
else if YI_3170=7 then do;
wcompP=50001;
flag_wcompP=2;
end;
end;
end;
if YI_2300=-1 or YI_3150=-1 or YI_3170=-1 then wcompP=-1;
else if YI_2300=-1 or YI_3150=-2 or YI_3170=-2 then wcompP=-2;
else if YI_2300=-1 or YI_3150=-3 or YI_3170=-3 then wcompP=-3;

*****this is the end of worker's compensation from R's partner/spouse*****;


*****************************************************************;
** Child support payment received by respondent or his/her partner/spouse - chsup**;
*****************************************************************;
chsup=-4;
if YI_3300=1 & YI_3900=1 then do;
flag_chsup=1;
if YI_4000=1 & YI_4100>=0 then chsup=YI_4100;
else if YI_4000=1 & YI_4100 in (-1,-2,-3) then do;
*if 1<=YI_4200<=7 then flag_chsup=2;
if YI_4200=1 then do;
chsup=500;
flag_chsup=2;
end;
else if YI_4200=2 then do;
chsup=1750;
flag_chsup=2;
end;
else if YI_4200=3 then do;
chsup=3750;
flag_chsup=2;
end;
else if YI_4200=4 then do;
chsup=7500;
flag_chsup=2;
end;
else if YI_4200=5 then do;
chsup=17500;
flag_chsup=2;
end;
else if YI_4200=6 then do;
chsup=37500;
flag_chsup=2;
end;
else if YI_4200=7 then do;
chsup=50001;
flag_chsup=2;
end;
end;
end;

if YI_3300=-1 or YI_3900=-1 or YI_4000=-1 or YI_4200=-1 then chsup=-1;
else if YI_3300=-2 or YI_3900=-2 or YI_4000=-2 or YI_4200=-2 then chsup=-2;
else if YI_3300=-1 or YI_3900=-1 or YI_4000=-3 or YI_4200=-3 then chsup=-3;

*****this is end of child support*****;


**************************************************************;
** Interest payments received by the respondent and r's partner/spouse - intrst **;
**************************************************************;

intrst=-4;
if YI_4300=1 then do;
flag_intrst=1;
if YI_4400>=0 then intrst=YI_4400;
else if YI_4400 in (-1,-2,-3) then do;
*if 1<=YI_4500<=7 then flag_intrst=2;
if YI_4500=1 then do;
intrst=250;
flag_intrst=2;
end;
else if YI_4500=2 then do;
intrst=750;
flag_intrst=2;
end;
else if YI_4500=3 then do;
intrst=1750;
flag_intrst=2;
end;
else if YI_4500=4 then do;
intrst=3750;
flag_intrst=2;
end;
else if YI_4500=5 then do;
intrst=6250;
flag_intrst=2;
end;
else if YI_4500=6 then do;
intrst=8750;
flag_intrst=2;
end;
else if YI_4500=7 then do;
intrst=10001;
flag_intrst=2;
end;
end;
end;

if YI_4300=-1 or YI_4500=-1 then intrst=-1;
else if YI_4300=-2 or YI_4500=-2 then intrst=-2;
else if YI_4300=-3 or YI_4500=-3 then intrst=-3;

*****this is the end of interest.*****;


*******************************************************;
** Dividends from stocks & mutual funds received by the respondent **;
** and his/her partner/spouse - dividend                                             **;
*******************************************************;
dvdend=-4;
if YI_4600=1 then do;
flag_dvdend=1;
if YI_4700>=0 then dvdend=YI_4700;
else if YI_4700 in (-1,-2,-3) then do;
*if 1<=YI_4800<=7 then flag_dvdend=2;
if YI_4800=1 then do;
dvdend=250;
flag_dvdend=2;
end;
else if YI_4800=2 then do;
dvdend=750;
flag_dvdend=2;
end;
else if YI_4800=3 then do;
dvdend=1750;
flag_dvdend=2;
end;
else if YI_4800=4 then do;
dvdend=3750;
flag_dvdend=2;
end;
else if YI_4800=5 then do;
dvdend=6250;
flag_dvdend=2;
end;
else if YI_4800=6 then do;
dvdend=8750;
flag_dvdend=2;
end;
else if YI_4800=7 then do;
dvdend=10001;
flag_dvdend=2;
end;
end;
end;

if YI_4600=-1 or YI_4800=-1 then dvdend=-1;
else if YI_4600=-2 or YI_4800=-2 then dvdend=-2;
else if YI_4600=-3 or YI_4800=-3 then dvdend=-3;

***** this is the end of dividends. *****;


***************************************************************;
** Rental income received by the respondent and his/her partner/spouse - rntinc **;
***************************************************************;

rntinc=-4;
if YI_4900=1 then do;
if YI_5000>=0 then rntinc=YI_5000;
else if YI_5000 in (-1,-2,-3) then do;

if YI_5100=1 then do;
rntinc=500;
flag_rntinc=2;
end;
else if YI_5100=2 then do;
rntinc=1750;
flag_rntinc=2;
end;
else if YI_5100=3 then do;
rntinc=3750;
flag_rntinc=2;
end;
else if YI_5100=4 then do;
rntinc=7500;
flag_rntinc=2;
end;
else if YI_5100=5 then do;
rntinc=17500;
flag_rntinc=2;
end;
else if YI_5100=6 then do;
rntinc=37500;
flag_rntinc=2;
end;
else if YI_5100=7 then do;
rntinc=50001;
flag_rntinc=2;
end;
end;
end;

if YI_4900=-1 or YI_5100=-1 then rntinc=-1;
else if YI_4900=-2 or YI_5100=-2 then rntinc=-2;
else if YI_4900=-3 or YI_5100=-3 then rntinc=-3;

***** this is the end of rental income. *****;


************************************************************;
** Property or money from estates, trusts, annuities or inheritances received **;
** by the respondent and his/her partner/spouse - astinc                               **;
************************************************************;

astinc=-4;
if YI_5200=1 then do;
flag_astinc=1;
if YI_5300>=0 then astinc=YI_5300;
else if YI_5300 in (-1,-2,-3) then do;
if 1<=YI_5400<=7 then flag_astinc=2;
if YI_5400=1 then astinc=2500;
else if YI_5400=2 then astinc=7500;
else if YI_5400=3 then astinc=17500;
else if YI_5400=4 then astinc=37500;
else if YI_5400=5 then astinc=75000;
else if YI_5400=6 then astinc=175000;
else if YI_5400=7 then astinc=250001;
end;
end;

if YI_5200=-1 or YI_5400=-1 then astinc=-1;
else if YI_5200=-2 or YI_5400=-2 then astinc=-2;
else if YI_5200=-3 or YI_5400=-3 then astinc=-3;

***** this is the end of estate,trusts,annuities or inheritances. *****;


/************************************
** income as gift from friends or family: gftinc **
*************************************/

/*******************************************************/
/** Gift part has a great change. So, we create a variable, giftFrom, to **/
/** indicate if the gifts all from outside, all inside, or both. Following     **/
/** codes create the variable giftfrom.                                                 **/
/*******************************************************/


array HIRELY (*) HIRELY01-HIRELY12; /* check who is in the household. */

do i=1 to dim(hirely);
if hirely(i)=3 then mother_in=1;
else if hirely(i)=4 then father_in=1;
else if hirely(i)=7 then Smother_in=1;
else if hirely(i)=8 then Sfather_in=1;
else if hirely(i)=11 then mil_in=1;
else if hirely(i)=12 then fil_in=1;
else if hirely(i) in (13,15,21) then sister_in=1;
else if hirely(i) in (14,18,22) then brother_in=1;
else if hirely(i)=27 then bil_in=1;
else if hirely(i)=28 then sil_in=1;
else if hirely(i)=29 then gmother_in=1;
else if hirely(i)=33 then gfather_in=1;
else if hirely(i)=61 then gmil_in=1;
else if hirely(i)=62 then gfil_in=1;
else if hirely(i)=69 then partner_in=1;
else if hirely(i)=85 then nonrel_in=1;
else if hirely(i)=84 then rel_in=1;
else if hirely(i) in (1,2,37,41,45,46,47,48,49,50,51,52,59,60,61,62,
63,64,65,66,67,70,71,72,73,74,75,78,79,82,83,86,87)
then gftothrel_in=1;
end;
/**********************/
/** inside=0 from outside; **/
/** inside=1 from inside;   **/
/** inside=2 don't know.  **/
/*********************/

array inside(*) inside1-inside20;
do i=1 to dim(inside);
inside(i)=-3;
end;

array from(*) from1-from20;

if from1=1 then do;
if mother_in=1 and father_in=1 then inside1=1;
else if mother_in^=1 and father_in^=1 then inside1=0;
else inside1=2;
end;


if from2=1 then do;
if mother_in=1 then inside2=1;
else inside2=0;
end;


if from3=1 then do;
if father_in=1 then inside3=1;
else inside3=0;
end;


if from4=1 then do;
if mother_in=1 and Sfather_in=1 then inside4=1;
else if mother_in^=1 and Sfather_in^=1 then inside4=0;
else inside4=2;
end;


if from5=1 then do;
if father_in=1 and Smother_in=1 then inside5=1;
else if father_in^=1 and Smother_in^=1 then inside5=0;
else inside5=2;
end;


if from6=1 then do;
if Sfather_in=1 then inside6=1;
else inside6=0;
end;


if from7=1 then do;
if Smother=1 then inside7=1;
else inside7=0;
end;


if from8=1 then do;
if sister_in^=1 and brother_in^=1 then inside8=0;
else inside8=2;
end;


if from9=1 then do;
if gmother_in=1 and gfather_in=1 then inside9=1;
else if gmother^=1 and gfather^=1 then inside9=0;
else inside9=2;
end;

if from10=1 then do;
if mil_in=1 and fil_in=1 then inside10=1;
else if mil_in^=1 and fil_in^=1 then inside10=0;
else inside10=2;
end;

if from11=1 then do;
if mil_in=1 then inside11=1;
else inside11=0;
end;

if from12=1 then do;
if fil_in=1 then inside12=1;
else inside12=0;
end;

if from13=1 then do;
if mil_in=1 and fil_in=1 then inside13=1;
else if mil_in^=1 and fil_in^=1 then inside13=0;
else inside13=2;
end;

if from14=1 then do;
if mil_in=1 and fil_in=1 then inside14=1;
else if mil_in^=1 and fil_in^=1 then inside14=0;
else inside14=2;
end;

if from15=1 then do;
if fil_in=1 then inside15=1;
else inside15=0;
end;

if from16=1 then do;
if mil_in=1 then inside16=1;
else inside16=0;
end;

if from17=1 then do;
if bil_in^=1 and sil_in^=1 then inside17=0;
else inside17=2;
end;

if from18=1 then do;
if gmil_in=1 and gfil_in=1 then inside18=1;
else if gmil_in^=1 and gfil_in^=1 then inside18=0;
else inside18=2;
end;

if from19=1 then do;
if gftothrel_in=1 or rel_in=1 then inside19=2;
else if gftothrel_in^=1 and rel_in^=1 then inside19=0;
end;

if from20=1 then do;
if nonrel_in=1 then inside20=2;
else inside20=0;
end;



if partner_in=1 and nonrel_in=1 then do;
do i=10 to 18;
if from(i)=1 then inside(i)=2;
end;
end;

flag0=0;
flag1=0;
flag2=0;

do i=1 to dim(inside);
if inside(i)=0 then flag0=1; /*from outside*/
else if inside(i)=1 then flag1=1; /*from inside*/
else if inside(i)=2 then flag2=1; /* don't knonw*/

end;

if flag1=0 and flag2=0 and flag0=1 then giftfrom=0; /*all from outside*/
else if flag2=0 and flag0=0 and flag1=1 then giftfrom=1; /*all from inside*/
else if flag0=1 and flag1=1 and flag2=0 then giftfrom=2; /*part */
else if flag2=1 then giftfrom=-3; /* don't knonw*/
if giftfrom=. then giftfrom=-3;

/***** This is the end of giftfrom. *****/


gftinc=-4;
gftinc2=-4;
if YI_5700A=1 then do;
flag_gftinc=1;
if YI_5900A=1 then gftinc=250;
if YI_5900A=2 then gftinc=750;
if YI_5900A=3 then gftinc=1750;
if YI_5900A=4 then gftinc=3750;
if YI_5900A=5 then gftinc=6250;
if YI_5900A=6 then gftinc=8750;
if YI_5900A=7 then gftinc=10001;
end;


if giftfrom=0 then gftinc2=gftinc; /* giftfrom=0 means all gift from outside. */
else if giftfrom=1 then gftinc2=0; /* giftfrom=1 means all gift from inside. */
else if giftfrom=2 and gftinc<=1000 then gftinc2=gftinc; /* giftfrom=2 means gift from both sources; if */
else if giftfrom=2 and gftinc>1000 then gftinc2=-3; /* amount<=1000, then add it; otherwise, -3. */
else if giftfrom=-3 and gftinc<=1000 then gftinc2=gftinc; /* giftfrom=-3 means don't know from where. if */
else if giftfrom=-3 and gftinc>1000 then gftinc2=-3; /* amount<=1000 then add it; otherwise, -3. */

if YI_5700A=-1 or YI_5900A=-1 then do; gftinc=-1; gftinc2=-1; end;
if YI_5700A=-2 or YI_5900A=-2 then do; gftinc=-2; gftinc2=-2; end;
if YI_5700A=-3 or YI_5900A=-3 then do; gftinc=-3; gftinc2=-3; end;

***** this is the end of gift income. *****


*************************************************************;
** Income from other sources: ss payments, pension and retirement income,    **;
** alimony, payments from insurance policies, etc. received by the respondent **;
** and his/her partner/spouse - othinc.                                                            **;
*************************************************************;

othinc=-4;
if YI_7600=1 then do;
flag_othinc=1;
if YI_7700>=0 then othinc=YI_7700;
else if YI_7700 in (-1,-2,-3) then do;
if 1<=YI_7800<=7 then flag_othinc=2;
if YI_7800=1 then othinc=500;
else if YI_7800=2 then othinc=1750;
else if YI_7800=3 then othinc=3750;
else if YI_7800=4 then othinc=7500;
else if YI_7800=5 then othinc=17500;
else if YI_7800=6 then othinc=37500;
else if YI_7800=7 then othinc=50001;
end;
end;

if YI_7600=-1 or YI_7800=-1 then othinc=-1;
else if YI_7600=-2 or YI_7800=-2 then othinc=-2;
else if YI_7600=-3 or YI_7800=-3 then othinc=-3;

***** this is the end of other income. *****;


/************************************************/
/** Income from father/father like or/and mother/mother like **/
/** the condition is R's age as of 12/31/2003 is less than 25. **/
/************************************************/
dadinc=-4;
mominc=-4;
mlginc=-4;
fmginc=-4;
if YI_8050=0 then do;


do i=1 to dim(HIRELY);
if HIRELY(i)=3 then lv_mom=1;
else if HIRELY(i)=4 then lv_dad=1;
else if HIRELY(i) in (6,8,10) then lv_odad=1;
else if HIRELY(i) in (5,7,9) then lv_omom=1;
end;

********************************************************;
** Income from Father.                                                                        **;
** Note: Identify whether the respondent's father lives in the household. **;
********************************************************;

dadinc=-4;

***********************************************************;
** If the respondent lived with his/her father, then father's income - dadinc. **;
***********************************************************;
if lv_dad=1 then do;
if YI_8700=1 then do;
flag_dadinc=1;
if YI_8800>=0 then dadinc=YI_8800;
else if YI_8700=1 & YI_8800 in (-1,-2,-3) then do;
if 1<=YI_8900<=7 then flag_dadinc=2;
if YI_8900=1 then dadinc=2500;
else if YI_8900=2 then dadinc=7500;
else if YI_8900=3 then dadinc=17500;
else if YI_8900=4 then dadinc=37500;
else if YI_8900=5 then dadinc=75000;
else if YI_8900=6 then dadinc=175000;
else if YI_8900=7 then dadinc=250001;
end;
end;
if YI_8700=-1 or YI_8900=-1 then dadinc=-1;
else if YI_8700=-2 or YI_8900=-2 then dadinc=-2;
else if YI_8700=-3 or YI_8900=-3 then dadinc=-3;
end;

***** this is the end of dadinc *****;

**********************************************************;
** Income from Mother.                                                                          **;
** Note: Identify whether the respondent's mother lived in the household. **;
**********************************************************;

mominc=-4;
**************************************************************;
** If the respondent lived with his/her mother, then mother's income - mominc. **;
**************************************************************;
if lv_mom=1 then do;
if YI_9200=1 then do;
flag_mominc=1;
if YI_9300>=0 then mominc=YI_9300;
else if YI_9300 in (-1,-2,-3) then do;
if 1<=YI_9400<=7 then flag_mominc=2;
if YI_9400=1 then mominc=2500;
else if YI_9400=2 then mominc=7500;
else if YI_9400=3 then mominc=17500;
else if YI_9400=4 then mominc=37500;
else if YI_9400=5 then mominc=75000;
else if YI_9400=6 then mominc=175000;
else if YI_9400=7 then mominc=250001;
end;
end;
if YI_9200=-1 or YI_9400=-1 then mominc=-1;
else if YI_9200=-2 or YI_9400=-2 then mominc=-2;
else if YI_9200=-3 or YI_9400=-3 then mominc=-3;
end;

***** this is the end of mominc *****;

***************************************;
** If the respondent lived with a male guardian, **;
** then male guardian's income - mlginc.           **;
***************************************;
mlginc=-4;
if YI_9600=1 then do;
if YI_9700=1 then do;
flag_mlginc=1;
if YI_9800>=0 then mlginc=YI_9800;
else if YI_9800 in (-1,-2,-3) then do;
if 1<=YI_9900<=7 then flag_mlginc=2;
if YI_9900=1 then mlginc=2500;
else if YI_9900=2 then mlginc=7500;
else if YI_9900=3 then mlginc=17500;
else if YI_9900=4 then mlginc=37500;
else if YI_9900=5 then mlginc=75000;
else if YI_9900=6 then mlginc=175000;
else if YI_9900=7 then mlginc=250001;
end;
end;
if YI_9700=-1 or YI_9900=-1 then mlginc=-1;
else if YI_9700=-2 or YI_9900=-2 then mlginc=-2;
else if YI_9700=-3 or YI_9900=-3 then mlginc=-3;
end;

***** the end of mlginc. *****;

****************************************;
** If the respondent lived with a female guardian, **;
** then female guardian's income - fmginc.           **;
****************************************;
fmginc=-4;
if YI_10100=1 then do;
if YI_10200=1 then do;
flag_fmginc=1;
if YI_10300>=0 then fmginc=YI_10300;
else if YI_10300 in (-1,-2,-3) then do;
if 1<=YI_10400<=7 then flag_fmginc=2;
if YI_10400=1 then fmginc=2500;
else if YI_10400=2 then fmginc=7500;
else if YI_10400=3 then fmginc=17500;
else if YI_10400=4 then fmginc=37500;
else if YI_10400=5 then fmginc=75000;
else if YI_10400=6 then fmginc=175000;
else if YI_10400=7 then fmginc=250001;
end;
end;
if YI_10200=-1 or YI_10400=-1 then fmginc=-1;
else if YI_10200=-2 or YI_10400=-2 then fmginc=-2;
else if YI_10200=-3 or YI_10400=-3 then fmginc=-3;
end;

***** the end of fmginc. *****;


end;

/*************************************************/
/** Income from other family members living with R: othfaminc **/
/*************************************************/

othfaminc=-4;
if YI_11600A>0 then do;
othfaminc=YI_11600A;
flag_othfaminc=1;
end;
else if YI_11600A in (-1, -2,-3) then do;
if 1<=YI_11700<=7 then flag_othfaminc=2;
if YI_11700=1 then othfaminc=2500;
else if YI_11700=2 then othfaminc=7500;
else if YI_11700=3 then othfaminc=17500;
else if YI_11700=4 then othfaminc=37500;
else if YI_11700=5 then othfaminc=75000;
else if YI_11700=6 then othfaminc=175000;
else if YI_11700=7 then othfaminc=250001;
end;

if YI_11700=-1 then othfaminc=-1;
else if YI_11700=-2 then othfaminc=-2;
else if YI_11700=-3 then othfaminc=-3;

***** this is the end of othfaminc *****;


****************************************************************;
** Compute the respondent's gross household income in the past year (groshhIY). **;
****************************************************************;

array varsY (*) nfarmY farmY wcompY nfarmP farmP wcompP chsup
intrst dvdend rntinc astinc gftinc2 othinc mominc
dadinc mlginc fmginc othfaminc prgamt ;

array flgsY (*) flag_nfarmY flag_farmY flag_wcompY flag_nfarmP flag_farmP flag_wcompP
flag_chsup flag_intrst flag_dvdend flag_rntinc flag_astinc flag_gftinc flag_othinc
flag_mominc flag_dadinc flag_mlginc flag_fmginc
flag_othfaminc flag_prgamt;
groshhIY=0;
do i=1 to dim(varsY);
if varsY(i) not in (-1,-2,-3,-4) then groshhIY=groshhIY+varsY(i);
else if varsY(i) in (-1,-2,-3) then flgsY(i)=varsY(i);
end;
groshhIY=round(groshhIY,1);
****************************************************;
** Code groshhIY as an invalid skip if there are invalid responses.**;
****************************************************;
do i=1 to dim(varsY);
if varsY(i)=-1 then do;
groshhIY=-1;
invskpGIY=1;
end;
else if varsY(i)=-2 then do;
groshhIY=-2;
invskpGIY=2;
end;
else if varsY(i)=-3 then do;
groshhIY=-3;
invskpGIY=3;
end;
end;


************************************************;
** Code groshhIY as -5 for all those respondents who were **;
** not interviewed in Round 8.                                             **;
************************************************;
if YI_1400=-5 then do;
groshhIY=-5;
nonintGIY=1;
end;


********************************;
** THIS IS THE END OF INCOME **;
********************************;

Return to top


*****************Section 2: Household Poverty Status*****************


******************************************;
** start of the income-poverty ratio section (povthr) **;
******************************************;

** Create the poverty thresholds taken from u.s.census' website **;
** - http://www.census.gov/hhes/poverty/threshld/thresh03.html **;

povert=-4;

if hhsize=-1 or under18=-1 then povert=-1;
if hhsize=-2 or under18=-2 then povert=-2;
if hhsize=-3 or under18=-3 then povert=-3;

** Check if there are only children under 18 in the household - check these cases again.;
only_under18_HH=0;
if hhsize>0 & under18>0 & hhsize=under18
then only_under18_HH=1;

if hhsize=1 then do;
if under18=0 then povert=9573;
else if under18=1 then povert=9573;
end;

else if hhsize=2 then do;
if under18=0 then povert=12321;
else if under18=1 then povert=12682;
else if under18=2 then povert=12682;
end;

else if hhsize=3 then do;
if under18=0 then povert=14393;
else if under18=1 then povert=14810;
else if under18=2 then povert=14824;
else if under18=3 then povert=14824;
end;

else if hhsize=4 then do;
if under18=0 then povert=18979;
else if under18=1 then povert=19289;
else if under18=2 then povert=18660;
else if under18=3 then povert=18725;
else if under18=4 then povert=18725;
end;

else if hhsize=5 then do;
if under18=0 then povert=22887;
else if under18=1 then povert=23220;
else if under18=2 then povert=22509;
else if under18=3 then povert=21959;
else if under18=4 then povert=21623;
else if under18=5 then povert=21623;
end;

else if hhsize=6 then do;
if under18=0 then povert=26324;
else if under18=1 then povert=26429;
else if under18=2 then povert=25884;
else if under18=3 then povert=25362;
else if under18=4 then povert=24586;
else if under18=5 then povert=24126;
else if under18=6 then povert=24126;
end;

else if hhsize=7 then do;
if under18=0 then povert=30289;
else if under18=1 then povert=30479;
else if under18=2 then povert=29827;
else if under18=3 then povert=29372;
else if under18=4 then povert=28526;
else if under18=5 then povert=27538;
else if under18=6 then povert=26454;
else if under18=7 then povert=26454;
end;

else if hhsize=8 then do;
if under18=0 then povert=33876;
else if under18=1 then povert=34175;
else if under18=2 then povert=33560;
else if under18=3 then povert=33021;
else if under18=4 then povert=32256;
else if under18=5 then povert=31286;
else if under18=6 then povert=30275;
else if under18=7 then povert=30019;
else if under18=8 then povert=30019;
end;

else if hhsize>=9 then do;
if under18=0 then povert=40751;
else if under18=1 then povert=40948;
else if under18=2 then povert=40404;
else if under18=3 then povert=39947;
else if under18=4 then povert=39196;
else if under18=5 then povert=38163;
else if under18=6 then povert=37229;
else if under18=7 then povert=36998;
else if under18>=8 then povert=35572;
end;

***** this is the end of threshold. *****;

************************************************************;
** Compute the respondent's gross household income to poverty level ratio. **;
************************************************************;

povthr=-4;
if groshhIY>=0 & povert>0 then povthr=round(((groshhIY*100)/povert),1);

** Code povthr as an invalid skip for those with invalid income or household size.;
if groshhIY=-1 or povert=-1 then do;
povthr=-1;
invskpPOV=1;
end;
if groshhIY=-2 or povert=-2 then do;
povthr=-2;
invskpPOV=2;
end;
if groshhIY=-3 or povert=-3 then do;
povthr=-3;
invskpPOV=3;
end;

** Code povthr as a valid skip for those without any gross income (-4 and not 0).;
if groshhIY=-4 then do;
povthr=-4;
vskpPOV=1;
end;

** Code povthr as -5 for all those repondents who were not interviewed in round 7.;
if YI_1400=-5 then do;
povthr=-5;
nonintPOV=1;
end;

if groshhIY in (-1,-2) then groshhIY=-3;
if povthr in (-1,-2) then povthr=-3;
run;

************************************************;
** THIS IS THE END OF INCOME-POVERTY RATIO. **;
************************************************;

Return to top


Participation in Government Programs

Variables Created:

Variables Used

      These variables are listed in a separate file (due to the length of the list).

This program creates several variables describing the respondent's participation in government programs for the economically disadvantaged.  During the interview, respondents report amounts received and months of participation in Aid to Families with Dependent Children (AFDC); food stamps; and Women, Infants, and Children (WIC).  There is also an "other assistance" question to capture information about any other government program from which respondents may have received assistance.  The interview also records amounts received from unemployment compensation and worker's compensation in separate question series; this program also creates variables describing respondents' participation in unemployment or worker's compensation.

The program to create these variables first creates a month-by-month participation array for five of the six categories (AFDC, food stamps, WIC, and other programs; unemployment compensation is calculated separately, and the array is not created for worker's compensation).  These month-by-month variables constitute part of the event history array for program participation; see appendix 7 for more information.  After all arrays are created, the program merges data to create the summary variables. 

Because worker's compensation can be reported either as a lump sum received on a single day or as payments over the period of time that the respondent was not working, the month-by-month array variables are no longer created for this category of program participation.  The total benefits received in each calendar year are calculated, but the weeks and months that compensation were received are not created.

Variable descriptions are as follows:

  1. CV_GOVNT_PRG_YR.XX - indicates the number of months in any given year (from 1980 to 2005) that R received any or all of the four programs - 1)Aid to Families with Dependent Children,  2)Women, Infant & Children, 3)Food Stamps and 4)Other Assistance.
     

  2. CV_GOVNT_PRG_EVER - indicates the total number of months (from 1980 to 2005) that R received any or all of the above four programs
     

  3. CV_AMT_GOVNT_PCM_PCY.XX - indicates the amount received in any or all of the above programs by R in any given year (from 1980 to 2005).

Created variable name on CD Created variable name in this program
CV_GOVNT_PRG_EVER GPEV
CV_GOVNT_PRG_YR.XX  GPRTTLXX
CV_AMT_GOVNT_PCM_PCY.XX GPATTLXX


HE=0;

if pubid=6978 then do;
ps20000m1=ps20000m11; ps20000y1=ps20000y11;
ps22600m1=ps22600m11; ps22600y1=ps22600y11;
HE=1;
end;
if pubid=6533 then do;
p22000m2=p22000m21; p22000y2=p22000y21;
HE=1;
end;

***** Create dataset for those not interviewed or not eligible for program participation;
data nonint; set merged;
if p1210 in (-5,-4);

array GPRTTL (26) GPRTTL80-GPRTTL99 GPRTTL00 GPRTTL01-GPRTTL05;
array GPATTL (26) GPATTL80-GPATTL99 GPATTL00 GPATTL01-GPATTL05;

do i=1 to dim(GPRTTL);
if p1210=-5 then do;
GPRTTL(i)=-5;
GPATTL(i)=-5;
end;
if p1210=-4 then do;
GPRTTL(i)=-4;
GPATTL(i)=-4;
end;
end;

if p1210=-5 then GPEV=-5;
if p1210=-4 then GPEV=-4;


***** Create dataset for those interviewed and eligible for program participation;
data int; set merged;
if p1210>-4;

intd=intdr8;
intm=intmr8;
inty=intyr8;

array dtps (*) dtps1-dtps8;
array dtp1 (*) dtpa1 dtpw1 dtpf1 dtpo1;
array dtp2 (*) dtpa2 dtpw2 dtpf2 dtpo2;
array dtp3 (*) dtpa3 dtpw3 dtpf3 dtpo3;
array dtp4 (*) dtpa4 dtpw4 dtpf4 dtpo4;
array dtp5 (*) dtpa5 dtpw5 dtpf5 dtpo5;
array dtp6 (*) dtpa6 dtpw6 dtpf6 dtpo6;
array dtp7 (*) dtpa7 dtpw7 dtpf7 dtpo7;
array dtp8 (*) dtpa8 dtpw8 dtpf8 dtpo8;

array dtp22 (4,8) dtp2a11-dtp2a14 dtp2a21-dtp2a24
dtp2w11-dtp2w14 dtp2w21-dtp2w24
dtp2f11-dtp2f14 dtp2f21-dtp2f24
dtp2o11-dtp2o14 dtp2o21-dtp2o24;
array dtp33 (4,8) dtp3a11-dtp3a14 dtp3a21-dtp3a24
dtp3w11-dtp3w14 dtp3w21-dtp3w24
dtp3f11-dtp3f14 dtp3f21-dtp3f24
dtp3o11-dtp3o14 dtp3o21-dtp3o24;


do i=1 to dim(dtps);
dtps(i)=0;
end;
do p=1 to 4;
dtp1(p)=0; dtp2(p)=0; dtp3(p)=0; dtp4(p)=0;
dtp5(p)=0; dtp6(p)=0; dtp7(p)=0; dtp8(p)=0;
do q=1 to 8;
dtp22(p,q)=0; dtp33(p,q)=0;
end;
end;

** Note: Abbreviations used in this program are as follows:
DLI - Date of last interview
DCI - Date of current interview
SDLI - Since date of last interview
NVPR - Never Prior - NVPR
CMS - Continuous month scheme
AFDC - Aid to Families with Dependent Children
WIC - Women, Infants and Children
FST - Food Stamps
OTH - Other Assistance
CV - Created Variables;




************* PART I ****************
** Define all the arrays used in this program **
************************************;

** (1) Created Variables;
array GPRTTL (26) GPRTTL80-GPRTTL99 GPRTTL00 GPRTTL01-GPRTTL05;
array GPATTL (26) GPATTL80-GPATTL99 GPATTL00 GPATTL01-GPATTL05;


** (2) Information from prior rounds;

* Interview month.;
array intmR (7) intmR1-intmR7;

* Interview year.;
array intyR (7) intyR1-intyR7;

* no. of months ever received.;
array gpevR (7) gpevR1-gpevR7;

* no. of months received in a given year.;
array gprttlR (7,26) gpr1ttl80-gpr1ttl99 gpr1ttl00 gpr1ttl01-gpr1ttl05
gpr2ttl80-gpr2ttl99 gpr2ttl00 gpr2ttl01-gpr2ttl05
gpr3ttl80-gpr3ttl99 gpr3ttl00 gpr3ttl01-gpr3ttl05
gpr4ttl80-gpr4ttl99 gpr4ttl00 gpr4ttl01-gpr4ttl05
gpr5ttl80-gpr5ttl99 gpr5ttl00 gpr5ttl01-gpr5ttl05
gpr6ttl80-gpr6ttl99 gpr6ttl00 gpr6ttl01-gpr6ttl05
gpr7ttl80-gpr7ttl99 gpr7ttl00 gpr7ttl01-gpr7ttl05;

* amount received in a given year.;
array gpattlR (7,26) gpa1ttl80-gpa1ttl99 gpa1ttl00 gpa1ttl01-gpa1ttl05
gpa2ttl80-gpa2ttl99 gpa2ttl00 gpa2ttl01-gpa2ttl05
gpa3ttl80-gpa3ttl99 gpa3ttl00 gpa3ttl01-gpa3ttl05
gpa4ttl80-gpa4ttl99 gpa4ttl00 gpa4ttl01-gpa4ttl05
gpa5ttl80-gpa5ttl99 gpa5ttl00 gpa5ttl01-gpa5ttl05
gpa6ttl80-gpa6ttl99 gpa6ttl00 gpa6ttl01-gpa6ttl05
gpa7ttl80-gpa7ttl99 gpa7ttl00 gpa7ttl01-gpa7ttl05;

* start date for each spell;
array csmR (7,4,4) csma_R1_1-csma_R1_4 csmw_R1_1-csmw_R1_4 csmf_R1_1-csmf_R1_4 csmo_R1_1-csmo_R1_4
csma_R2_1-csma_R2_4 csmw_R2_1-csmw_R2_4 csmf_R2_1-csmf_R2_4 csmo_R2_1-csmo_R2_4
csma_R3_1-csma_R3_4 csmw_R3_1-csmw_R3_4 csmf_R3_1-csmf_R3_4 csmo_R3_1-csmo_R3_4
csma_R4_1-csma_R4_4 csmw_R4_1-csmw_R4_4 csmf_R4_1-csmf_R4_4 csmo_R4_1-csmo_R4_4
csma_R5_1-csma_R5_4 csmw_R5_1-csmw_R5_4 csmf_R5_1-csmf_R5_4 csmo_R5_1-csmo_R5_4
csma_R6_1-csma_R6_4 csmw_R6_1-csmw_R6_4 csmf_R6_1-csmf_R6_4 csmo_R6_1-csmo_R6_4
csma_R7_1-csma_R7_4 csmw_R7_1-csmw_R7_4 csmf_R7_1-csmf_R7_4 csmo_R7_1-csmo_R7_4;

* stop date for each spell;
array cemR (7,4,4) cema_R1_1-cema_R1_4 cemw_R1_1-cemw_R1_4 cemf_R1_1-cemf_R1_4 cemo_R1_1-cemo_R1_4
cema_R2_1-cema_R2_4 cemw_R2_1-cemw_R2_4 cemf_R2_1-cemf_R2_4 cemo_R2_1-cemo_R2_4
cema_R3_1-cema_R3_4 cemw_R3_1-cemw_R3_4 cemf_R3_1-cemf_R3_4 cemo_R3_1-cemo_R3_4
cema_R4_1-cema_R4_4 cemw_R4_1-cemw_R4_4 cemf_R4_1-cemf_R4_4 cemo_R4_1-cemo_R4_4
cema_R5_1-cema_R5_4 cemw_R5_1-cemw_R5_4 cemf_R5_1-cemf_R5_4 cemo_R5_1-cemo_R5_4
cema_R6_1-cema_R6_4 cemw_R6_1-cemw_R6_4 cemf_R6_1-cemf_R6_4 cemo_R6_1-cemo_R6_4
cema_R7_1-cema_R7_4 cemw_R7_1-cemw_R7_4 cemf_R7_1-cemf_R7_4 cemo_R7_1-cemo_R7_4;

* edit flag for dates for each spell;
array eflR (7,4,4) efla_R1_1-efla_R1_4 eflw_R1_1-eflw_R1_4 eflf_R1_1-eflf_R1_4 eflo_R1_1-eflo_R1_4
efla_R2_1-efla_R2_4 eflw_R2_1-eflw_R2_4 eflf_R2_1-eflf_R2_4 eflo_R2_1-eflo_R2_4
efla_R3_1-efla_R3_4 eflw_R3_1-eflw_R3_4 eflf_R3_1-eflf_R3_4 eflo_R3_1-eflo_R3_4
efla_R4_1-efla_R4_4 eflw_R4_1-eflw_R4_4 eflf_R4_1-eflf_R4_4 eflo_R4_1-eflo_R4_4
efla_R5_1-efla_R5_4 eflw_R5_1-eflw_R5_4 eflf_R5_1-eflf_R5_4 eflo_R5_1-eflo_R5_4
efla_R6_1-efla_R6_4 eflw_R6_1-eflw_R6_4 eflf_R6_1-eflf_R6_4 eflo_R6_1-eflo_R6_4
efla_R7_1-efla_R7_4 eflw_R7_1-eflw_R7_4 eflf_R7_1-eflf_R7_4 eflo_R7_1-eflo_R7_4;

* edit flag for amounts for each spell;
array aflR (7,4,4) afla_R1_1-afla_R1_4 aflw_R1_1-aflw_R1_4 aflf_R1_1-aflf_R1_4 aflo_R1_1-aflo_R1_4
afla_R2_1-afla_R2_4 aflw_R2_1-aflw_R2_4 aflf_R2_1-aflf_R2_4 aflo_R2_1-aflo_R2_4
afla_R3_1-afla_R3_4 aflw_R3_1-aflw_R3_4 aflf_R3_1-aflf_R3_4 aflo_R3_1-aflo_R3_4
afla_R4_1-afla_R4_4 aflw_R4_1-aflw_R4_4 aflf_R4_1-aflf_R4_4 aflo_R4_1-aflo_R4_4
afla_R5_1-afla_R5_4 aflw_R5_1-aflw_R5_4 aflf_R5_1-aflf_R5_4 aflo_R5_1-aflo_R5_4
afla_R6_1-afla_R6_4 aflw_R6_1-aflw_R6_4 aflf_R6_1-aflf_R6_4 aflo_R6_1-aflo_R6_4
afla_R7_1-afla_R7_4 aflw_R7_1-aflw_R7_4 aflf_R7_1-aflf_R7_4 aflo_R7_1-aflo_R7_4;

** (3) Intermediate variables - latest created variables available from prior rounds.;

* ogpev - no. of months ever received.;

* no. of months recd., yearly;
array ogprttl (26) ogprttl80-ogprttl99 ogprttl00 ogprttl01-ogprttl05;

* amount recd., yearly;
array ogpattl (26) ogpattl80-ogpattl99 ogpattl00 ogpattl01-ogpattl05;

* start date;
array ocsm (4) ocsma ocsmw ocsmf ocsmo;

* stop date;
array ocem (4) ocema ocemw ocemf ocemo;

* edit flag for dates;
array oefl (4) oefla oeflw oeflf oeflo;

* edit flag for amounts;
array oafl (4) oafla oaflw oaflf oaflo;

** (4) (Raw data) Information available from current round.;

* START YEAR information;
array ys (4,8) ps35800y1-ps35800y4 p16700y1-p16700y4
ps22000y1-ps22000y4 p22000y1-p22000y4
ps19100y1-ps19100y4 p19400y1-p19400y4
ps31000y1-ps31000y4 p31000y1-p31000y4;

* START MONTH information;
array ms (4,8) ps35800m1-ps35800m4 p16700m1-p16700m4
ps22000m1-ps22000m4 p22000m1-p22000m4
ps19100m1-ps19100m4 p19400m1-p19400m4
ps31000m1-ps31000m4 p31000m1-p31000m4;

* END YEAR information;
array ye (4,8) ps35840y1-ps35840y4 p17200y1-p17200y4
ps22600y1-ps22600y4 p22600y1-p22600y4
ps20000y1-ps20000y4 p20000y1-p20000y4
ps31600y1-ps31600y4 p31600y1-p31600y4;


* END MONTH information;
array me (4,8) ps35840m1-ps35840m4 p17200m1-p17200m4
ps22600m1-ps22600m4 p22600m1-p22600m4
ps20000m1-ps20000m4 p20000m1-p20000m4
ps31600m1-ps31600m4 p31600m1-p31600m4;

* CURRENTLY RECEIVING information - NO GAPS;
array cur (4,8) ps359501-ps359504 p169001-p169004
ps23700a1-ps23700a4 p222001-p222004
ps21100a1-ps21100a4 p196001-p196004
ps32700a1-ps32700a4 p312001-p312004;

* CURRENTLY RECEIVING information - RETRO;
array cwks (4,8) ps35740 ps35740 ps35740 ps35740 p16200 p16200 p16200 p16200
ps21430 ps21430 ps21430 ps21430 p21500 p21500 p21500 p21500
ps16410 ps16410 ps16410 ps16410 p18900 p18900 p18900 p18900
ps36120 ps36120 ps36120 ps36120 p30500 p30500 p30500 p30500;

* PERSON was RECEIVING AT DLI, chk;
array dli (4,8) ps357901 duma2-duma8
ps21900a1 dumw2-dumw8
ps19063a1 dumf2-dumf8
ps30900a1 dumo2-dumo8;

* AMOUNT RECEIVED - ACTUAL;
array incm (4,8) ps359001-ps359004 p181001-p181004
ps233001-ps233004 p233001-p233004
ps207001-ps207004 p207001-p207004
ps323001-ps323004 p323001-p323004;

* AMOUNT RECEIVED - ESTIMATED;
array eincm (4,8) ps359101-ps359104 p182001-p182004
ps234001-ps234004 p234001-p234004
ps208001-ps208004 p208001-p208004
ps324001-ps324004 p324001-p324004;

* ESTIMATED WEEKS - unable to answer start or stop quex;
array wks (4,8) ps358601-ps358604 p175001-p175004
ps228001-ps228004 p228001-p228004
ps202001-ps202004 p202001-p202004
ps318001-ps318004 p318001-p318004;

* STOPPED FOR 2+ WEEKS.;
array stpgp (4,8) ps358301-ps358304 p170001-p170004
ps223001-ps223004 p223001-p223004
ps197001-ps197004 p197001-p197004
ps313001-ps313004 p313001-p313004;

* RECEIVE AGAIN?;
array recag (4,8) ps359601-ps359604 p186001-p186004
ps238001-ps238004 p238001-p238004
ps212001-ps212004 p212001-p212004
ps329001-ps329004 p329001-p329004;

* PERSON RECEIVING, R;
array rcvr (4,8) ps359201_1-ps359201_4 p183001_1-p183001_4
ps235001_1-ps235001_4 p235001_1-p235001_4
ps209001_1-ps209001_4 p209001_1-p209001_4
ps325001_1-ps325001_4 p325001_1-p325001_4;

* PERSON RECEIVING, SPOUSE;
array rcvs (4,8) ps359202_1-ps359202_4 p183002_1-p183002_4
ps235002_1-ps235002_4 p235002_1-p235002_4
ps209002_1-ps209002_4 p209002_1-p209002_4
ps325002_1-ps325002_4 p325002_1-p325002_4;

* PERSON RECEIVING, CHILD;
array rcvc (4,8) ps359203_1-ps359203_4 p183003_1-p183003_4
ps235003_1-ps235003_4 p235003_1-p235003_4
ps209003_1-ps209003_4 p209003_1-p209003_4
ps325003_1-ps325003_4 p325003_1-p325003_4;

* PERSON RECEIVING, FAMILY MEMBER;
array rcvf (4,8) ps359204_1-ps359204_4 p183004_1-p183004_4
ps235004_1-ps235004_4 p235004_1-p235004_4
ps209004_1-ps209004_4 p209004_1-p209004_4
ps325004_1-ps325004_4 p325004_1-p325004_4;

* PERSON RECEIVING, OTHER PERSON;
array rcvo (4,8) ps359205_1-ps359205_4 p183005_1-p183005_4
ps235005_1-ps235005_4 p235005_1-p235005_4
ps209005_1-ps209005_4 p209005_1-p209005_4
ps325005_1-ps325005_4 p325005_1-p325005_4;


** (5) Intermediate variables created based on information available from current round.;

* indicator for receipt, monthly.; * amount received, monthly.; * person receiving, monthly.;
array AREC (312) AREC001-AREC312; array AAMT (312) AAMT001-AAMT312; array AHHM (312) AHHM001-AHHM312;
array WREC (312) WREC001-WREC312; array WAMT (312) WAMT001-WAMT312; array WHHM (312) WHHM001-WHHM312;
array FREC (312) FREC001-FREC312; array FAMT (312) FAMT001-FAMT312; array FHHM (312) FHHM001-FHHM312;
array OREC (312) OREC001-OREC312; array OAMT (312) OAMT001-OAMT312; array OHHM (312) OHHM001-OHHM312;

array ALLAMT (4,312) AAMT001-AAMT312 WAMT001-WAMT312 FAMT001-FAMT312 OAMT001-OAMT312;
array ALLREC (4,312) AREC001-AREC312 WREC001-WREC312 FREC001-FREC312 OREC001-OREC312;
array ALLHHM (4,312) AHHM001-AHHM312 WHHM001-WHHM312 FHHM001-FHHM312 OHHM001-OHHM312;

* ttlg - no. of months ever received.;

* no. of months received, yearly.;
array gm (26) gm80-gm99 gm00 gm01-gm05;

* amount received, yearly.;
array gamt(26) gamt80-gamt99 gamt00 gamt01-gamt05;

* no. of months with valid amounts.;
array ga (26) ga80-ga99 ga00 ga01-ga05;

* no. of months with invalid amounts.;
array gn (26) gn80-gn99 gn00 gn01-gn05;

* start date in YYYYMM scheme;
array yms (4,8) ymsa11-ymsa14 ymsa21-ymsa24
ymsw11-ymsw14 ymsw21-ymsw24
ymsf11-ymsf14 ymsf21-ymsf24
ymso11-ymso14 ymso21-ymso24;

* start date in CMS;
array csm (4,8) csma11-csma14 csma21-csma24
csmw11-csmw14 csmw21-csmw24
csmf11-csmf14 csmf21-csmf24
csmo11-csmo14 csmo21-csmo24;

* stop date in YYYYMM scheme;
array yme (4,8) ymea11-ymea14 ymea21-ymea24
ymew11-ymew14 ymew21-ymew24
ymef11-ymef14 ymef21-ymef24
ymeo11-ymeo14 ymeo21-ymeo24;

* stop date in CMS;
array cem (4,8) cema11-cema14 cema21-cema24
cemw11-cemw14 cemw21-cemw24
cemf11-cemf14 cemf21-cemf24
cemo11-cemo14 cemo21-cemo24;

* amount received;
array inc (4,8) inca11-inca14 inca21-inca24
incw11-incw14 incw21-incw24
incf11-incf14 incf21-incf24
inco11-inco14 inco21-inco24;

* person receiving dummy;
array who (4,8) whoa11-whoa14 whoa21-whoa24
whow11-whow14 whow21-whow24
whof11-whof14 whof21-whof24
whoo11-whoo14 whoo21-whoo24;

* estimated months;
array mos (4,8) mosa11-mosa14 mosa21-mosa24
mosw11-mosw14 mosw21-mosw24
mosf11-mosf14 mosf21-mosf24
moso11-moso14 moso21-moso24;

* start month;
array nms (4,8) nmsa11-nmsa14 nmsa21-nmsa24
nmsw11-nmsw14 nmsw21-nmsw24
nmsf11-nmsf14 nmsf21-nmsf24
nmso11-nmso14 nmso21-nmso24;

* date flag;
array efl (4,8) efla11-efla14 efla21-efla24
eflw11-eflw14 eflw21-eflw24
eflf11-eflf14 eflf21-eflf24
eflo11-eflo14 eflo21-eflo24;

* amount flag;
array afl (4,8) afla11-afla14 afla21-afla24
aflw11-aflw14 aflw21-aflw24
aflf11-aflf14 aflf21-aflf24
aflo11-aflo14 aflo21-aflo24;

* date flag (when end date is before DLI);
array nefl (4,8) nefla11-nefla14 nefla21-nefla24
neflw11-neflw14 neflw21-neflw24
neflf11-neflf14 neflf21-neflf24
neflo11-neflo14 neflo21-neflo24;

* age flag;
array agfl (4,8) agfla11-agfla14 agfla21-agfla24
agflw11-agflw14 agflw21-agflw24
agflf11-agflf14 agflf21-agflf24
agflo11-agflo14 agflo21-agflo24;

** (6) Variables created for use in checking the created variables.;

* To check for spells that ended before DLI.;
array edli (4,8) edlia11-edlia14 edlia21-edlia24
edliw11-edliw14 edliw21-edliw24
edlif11-edlif14 edlif21-edlif24
edlio11-edlio14 edlio21-edlio24;

* date flag to be used for checking "efl";
array eflC (4,8) eflCa11-eflCa14 eflCa21-eflCa24
eflCw11-eflCw14 eflCw21-eflCw24
eflCf11-eflCf14 eflCf21-eflCf24
eflCo11-eflCo14 eflCo21-eflCo24;

* To check for spells that have start dates before end dates.;
array rvdt (4,8) rvdta11-rvdta14 rvdta21-rvdta24
rvdtw11-rvdtw14 rvdtw21-rvdtw24
rvdtf11-rvdtf14 rvdtf21-rvdtf24
rvdto11-rvdto14 rvdto21-rvdto24;

* To check for spells that have start dates before end dates.;
array dtms (4,8) dtmsa11-dtmsa14 dtmsa21-dtmsa24
dtmsw11-dtmsw14 dtmsw21-dtmsw24
dtmsf11-dtmsf14 dtmsf21-dtmsf24
dtmso11-dtmso14 dtmso21-dtmso24;


* temporary start date in CMS;
array tcsm (4,8) tcsma11-tcsma14 tcsma21-tcsma24
tcsmw11-tcsmw14 tcsmw21-tcsmw24
tcsmf11-tcsmf14 tcsmf21-tcsmf24
tcsmo11-tcsmo14 tcsmo21-tcsmo24;

* temporary stop date in CMS;
array tcem (4,8) tcema11-tcema14 tcema21-tcema24
tcemw11-tcemw14 tcemw21-tcemw24
tcemf11-tcemf14 tcemf21-tcemf24
tcemo11-tcemo14 tcemo21-tcemo24;

* temporary amount received;
array tinc (4,8) tinca11-tinca14 tinca21-tinca24
tincw11-tincw14 tincw21-tincw24
tincf11-tincf14 tincf21-tincf24
tinco11-tinco14 tinco21-tinco24;

* temporary person receiving dummy;
array twho (4,8) twhoa11-twhoa14 twhoa21-twhoa24
twhow11-twhow14 twhow21-twhow24
twhof11-twhof14 twhof21-twhof24
twhoo11-twhoo14 twhoo21-twhoo24;

* temporary date flag;
array tefl (4,8) tefla11-tefla14 tefla21-tefla24
teflw11-teflw14 teflw21-teflw24
teflf11-teflf14 teflf21-teflf24
teflo11-teflo14 teflo21-teflo24;

* temporary amount flag;
array tafl (4,8) tafla11-tafla14 tafla21-tafla24
taflw11-taflw14 taflw21-taflw24
taflf11-taflf14 taflf21-taflf24
taflo11-taflo14 taflo21-taflo24;

array prgms1 (4) AFDC_SDLI WIC_SDLI FST_SDLI OTH_SDLI; * Flag for whether program was reported in SDLI.;
array prgms2 (4) AFDC_NVPR WIC_NVPR FST_NVPR OTH_NVPR; * Flag for whether program was reported in NVPR.;
array stdlis (4) stdlia stdliw stdlif stdlio; * Flag for progs whose spells started before DLI.;
array endlis (4) endlia endliw endlif endlio; * Flag for progs whose spells ended before DLI.;
array revdts (4) revdta revdtw revdtf revdto; * Flag for progs with spell st dts. later than end dts.;
array dtmiss (4) dtmisa dtmisw dtmisf dtmiso; * Flag for progs with either spell start/stop dts missing;
array ovp (4) ovpa ovpw ovpf ovpo; * Flag for progs with overlapping spells.;
array whybt (4) whybta whybtw whybtf whybto; * Flag for reporting in both SDLI and NVPR.;
array whodf (4) whodfa whodfw whodff whodfo; * Flag for different person receiving overlapping spells.;
array whyms (4) whymsa whymsw whymsf whymso; * Flag for non-rec. in CVs even though reported.;
array doipr (4) doipra doiprw doiprf doipro; * Flag for receiving after DCI (as per CVs).;
array prgms (4) AFDC WIC FST OTH; * Flag for program receipiency (as per CVs).;


******************************** PART II ***********************************
** Initialize the created and intermediate variables at the value at DLI or 0. Create date of birth, **
** DCI, DLI etc. in CMS and YYYYMM schemes.                                                                 **
***************************************************************************;

rnds=dim(csm,2);
rnds1=dim(csm,2)/2;

** Identify the last round that R was interviewed (dli_rnd);
do i=1 to dim(intmR);
if intmR(i)~=-5 then dli_rnd=i;
end;

** Intialize values of GPRTTL (& ogprttl), GPATTL (& ogpattl) and GPEV (& ogpev) by their values at the
DLI;
do i=1 to dim(intmR);
if i=dli_rnd then do;
GPEV=gpevR(i);
ogpev=gpevR(i);
do j=1 to dim(GPRTTL);
GPRTTL(j)=gprttlR(i,j);
GPATTL(j)=gpattlR(i,j);
ogprttl(j)=gprttlR(i,j);
ogpattl(j)=gpattlR(i,j);
end;
end;
end;

** Identify the start and stop dates and edit flags for those dates for the last spell reported in prior
rounds - ocsma ocsmw ocsmf ocsmo ocema ocemw ocemf ocemo
oefla oeflw oeflf oeflo oafla oaflw oaflf oaflo;
do i=1 to dim(csmR,1);
do p=1 to dim(csmR,2);
do t=1 to dim(csmR,3);
if csmR(i,p,t)>-4 then do;
ocsm(p)=csmR(i,p,t);
ocem(p)=cemR(i,p,t);
oefl(p)=eflR(i,p,t);
oafl(p)=aflR(i,p,t);
end;
end;
end;
end;


** Take care of cases in earlier rounds;
do j=1 to dim(GPRTTL);
* although R did not participate in govt. programs, the amount received variable is 0 instead of -4.;
if GPRTTL(j)=0 and GPATTL(j)=0 then ogpattl(j)=-4;

* GPRTTL was not computed for anyone and so appears missing for all R;
if GPRTTL(j)=. or GPRTTL(j)=-4 then do;
ogprttl(j)=-4;
GPRTTL(j)=0;
end;

* GPATTL was not computed for anyone and so appears missing for all R;
if GPATTL(j)=. or GPATTL(j)=-4 then do;
ogpattl(j)=-4;
GPATTL(j)=0;
end;
end;

** Initialize value of GPEV to 0 if it is a valid skip;
if GPEV=. or GPEV=-4 then do;
ogpev=-4;
GPEV=0;
end;

** Create various important date variables in the two schemes - the YYYYMM scheme and the continuous
month scheme (CMS)
ymb - Date of Birth in YYYYMM scheme
cmb - Date of Birth in CMS
ym14 - Date of 14th birthday in YYYYMM scheme
cm14 - Date of 14th birthday in CMS
dliym - month after DLI in YYYYMM scheme
dlicm - month after DLI in CMS
cdli - DLI in CMS
iym - DCI in YYYYMM scheme
doicm - DCI in CMS
mnthaf - month after CDI
aaiym - Age at DCI in YYYYMM scheme
aaicm - Age at DCI in CMS;


ymb=(doby*100)+dobm;
cmb=((doby-1980)*12)+dobm;
ym14=ymb+1400;
cm14=cmb+(14*12);

if inty>0 and intm>0 then do;
iym=(inty*100)+intm;
doicm=((inty-1980)*12)+intm;
mnthaf=doicm+1;
aaiym=iym-ymb;
aaicm=doicm-cmb;
end;
if inty in (-1,-2,-3) or intm in (-1,-2,-3) then do;
iym=-3;
doicm=-3;
aaiym=-3;
aaicm=-3;
end;

if p1210=1 then do;
do i=1 to dim(intmR);
if i=dli_rnd then do;
if intmR(i)<12 then dliym=(intyR(i)*100)+intmR(i)+1;
if intmR(i)=12 then dliym=((intyR(i)+1)*100)+1;
dlicm=((intyR(i)-1980)*12)+intmR(i)+1;
cdli=((intyR(i)-1980)*12)+intmR(i);
end;
end;
end;
if p1210~=1 then do;
dliym=ym14;
dlicm=cm14;
cdli=cm14-1;
end;


** Initialize values of the monthly variables to be created;
do l=cmb to doicm;
AREC(l)=0;
WREC(l)=0;
FREC(l)=0;
OREC(l)=0;
end;

** Initialize the following counters to zero. ;
ackr=0; wckr=0; fckr=0; ockr=0; * Counter=1 when XREC>0 but XAMT in (.,-4).;
acka=0; wcka=0; fcka=0; ocka=0; * Counter=1 when XREC=0 or XHHM in (.,-4) but XAMT>-4;
ackh=0; wckh=0; fckh=0; ockh=0; * Counter=1 when XREC=0 or XAMT in (.,-4) but XHHM>-4;
ackv=0; wckv=0; fckv=0; ockv=0; * Counter=1 when XREC=-3 but XAMT~=-3.;
aodttl=0; wodttl=0; fodttl=0; oodttl=0; * Counter for total no. of months received the problematic amts.;


*** Initialize variables;
/*** Not required in this round - these variables are not available in this round
** Merge values of "currently receiving" variable from two different sections of the questionnaire;
if ps35707>-3 then p16200=ps35707; * AFDC;
if ps21397>-3 then p21500=ps21397; * WIC;
if ps16377>-3 then p18900=ps16377; * FST;
if ps36087>-3 then p30500=ps36087; * OTH;
***/


********************** PART III *************************
** Create intermediate variables using informaiton from current round. **
********************************************************;
do p=1 to 4; /** [B1] **/
do q=1 to dim(csm,2); /** [B2] **/

*** Create variables that indicate the start and stop dates for a particular spell of a
particular program in the yyyymm and CSM formats;
*****************************************************
** Define the start date and end dates. If R reports still receiving, then use DCI as the **
** temporary end date for the last loop reported. In the next survey round, R will be asked **
** if he or she is still receiving. If not, then a permanent end date equivalent to the **
** interview date of the last round will be assigned. If start or end dates are missing, **
** impute those dates. Users will be able to tell what was imputed by looking at the **
** following participation flag variable created during the program. The categories are the **
** following: **
** 1=R reported participation dates **
** 2=start month imputed **
** 3=start month and year imputed **
** 4=stop month imputed **
** 5=stop month and year imputed **
** 6=start and stop dates imputed **
** 7=err_or in data due to round 8 questionnaire problems or inconsistent response. **
** Both result in us not being sure whether Rs received in these months or not. **
** QUESTIONNAIRE err_or: These Rs reported valid start and stop dates but were **
** never asked the follow-up question - if they received **
** again. **
** CONFLICTING RESPONSE: These Rs reported currently receiving, a valid start **
** date and a valid stop date that is different from the **
** DCI but in the follow-up question as to whether they **
** received again, they answered NO. **
*********************************;


** (1) Set start date if both start month and year are valid;

if ys(p,q)>0 and ms(p,q)>0 then yms(p,q)=(ys(p,q)*100)+ms(p,q);

* set start date to DLI if receiving then;
if dli(p,q)=1 then do;
yms(p,q)=dliym;
if cwks(p,q)=1 then do;
yme(p,q)=iym;
nogaps=p;
end;
end;

* Set end date to DCI if receiving now;
if cur(p,q)=1 then yme(p,q)=iym;

* Set end date if both end month and year are valid;
if ye(p,q)>0 and me(p,q)>0 then yme(p,q)=(ye(p,q)*100)+me(p,q);

* If end month greater than DCI, constrain by DCI;
if yme(p,q)>iym then yme(p,q)=iym;

* Efl is not set iff the end date is before DLI. Only in these cases we do not compute months
receiving variable. So, we use another efl variable just to know the efl value;
if yms(p,q)>0 and yme(p,q)>=dliym then efl(p,q)=1;
if yms(p,q)>0 and 0<yme(p,q)<dliym then nefl(p,q)=1;

* Determine months from estimated weeks variable;
if wks(p,q)>=0 and (ys(p,q)<0 or ms(p,q)<0 or ye(p,q)<0 or me(p,q)<0) then do;
mos(p,q)=floor(wks(p,q)/4.3);
end;

* Age edit flag;
agfl(p,q)=0;
if ys(p,q)>0 and ys(p,q)<1990 then agfl(p,q)=1;

** (2) If start year is known and month is unknown;

if ys(p,q)>0 and -3<=ms(p,q)<=-1 then do;

* If weeks are known and currently receiving, then count backwards by the number of weeks from
the DCI. If the number of weeks falls short of the start year, the start month is December
of that year. If the number of weeks is past the start year, then the start month is January
of that year.;
if wks(p,q)>=0 and cwks(p,q)=1 then do;
yme(p,q)=iym;
if 0<=mos(p,q)<=(intm-1) then yms(p,q)=iym-mos(p,q);
do k=1 to 13;
A=(k*88);
if (intm+(k*12)-12)<=mos(p,q)<=(intm+(k*12)-1) then yms(p,q)=iym-A-mos(p,q);
end;
if yms(p,q)<((ys(p,q)*100)+01) then yms(p,q)=((ys(p,q)*100)+01);
if yms(p,q)<dliym then yms(p,q)=dliym;
if yms(p,q)>((ys(p,q)*100)+12) then yms(p,q)=((ys(p,q)*100)+12);
end;

* Weeks missing and currently receiving - set end date to DCI and start date to Dec of start
year;
else if -3<=wks(p,q)<0 and cwks(p,q)=1 then do;
yme(p,q)=iym;
yms(p,q)=((ys(p,q)*100)+12);
if yms(p,q)>iym then yms(p,q)=iym;
end;

* Weeks missing and not currently receiving - set end date to Dec and start date to Jan of
start year, constrain end date by DCI;
else if -3<=wks(p,q)<0 and cwks(p,q)=0 then do;
yms(p,q)=((ys(p,q)*100)+01);
if yms(p,q)<dliym then yms(p,q)=dliym;
if yms(p,q)>((ys(p,q)*100)+12) then yms(p,q)=((ys(p,q)*100)+12);
if yme(p,q)=. then yme(p,q)=((ys(p,q)*100)+12);
if yme(p,q)>iym then yme(p,q)=iym;
end;

* If weeks are known and not currently receiving, then put start date as Jan of start year.
Constrain by DLI. But finally constrain by Dec of start year. Then count forward by the
number of weeks from start date. Constrain end date by DCI;
else if wks(p,q)>=0 and cwks(p,q)=0 then do;
yms(p,q)=((ys(p,q)*100)+01);
if yms(p,q)<dliym then yms(p,q)=dliym;
nms(p,q)=yms(p,q)-round(yms(p,q),100);
if 0<=mos(p,q)<=(12-nms(p,q)) then yme(p,q)=yms(p,q)+mos(p,q);
do k=1 to 13;
A=(k*88);
if ((k*12)+1-nms(p,q))<=mos(p,q)<=((k*12)+12-nms(p,q)) then yme(p,q)=yms(p,q)+A+mos(p,q);
end;
if yme(p,q)>iym then yme(p,q)=iym;
end;

* If end date is known (then estimated weeks is not asked and so wks=-4). Then set start
date to Jan of start year;
if yme(p,q)>0 and wks(p,q)=-4 then yms(p,q)=((ys(p,q)*100)+01);
if yms(p,q)<dliym then yms(p,q)=dliym;
if yms(p,q)>((ys(p,q)*100)+12) then yms(p,q)=((ys(p,q)*100)+12);

efl(p,q)=2;
end;


** (3) If start year is unknown;

if -3<=ys(p,q)<=-1 then do;

* If weeks are known then count back from DCI if currently receiving.;
if wks(p,q)>=0 and cwks(p,q)=1 then do;
yme(p,q)=iym;
if 0<=mos(p,q)<=(intm-1) then yms(p,q)=iym-mos(p,q);
do k=1 to 13;
A=(k*88);
if (intm+(k*12)-12)<=mos(p,q)<=(intm+(k*12)-1) then yms(p,q)=iym-A-mos(p,q);
end;
if yms(p,q)<dliym then yms(p,q)=dliym;
end;

* If weeks missing and currently receiving - set start date to DLI and end date to DCI;
if -3<=wks(p,q)<0 and cwks(p,q)=1 then do;
yms(p,q)=dliym;
yme(p,q)=iym;
end;

* weeks are known and not currently receiving then count backward from DCI/or stop date if
known and set Jan of that year as the start year. Then add the number of months receiving
and get the stop date. Constrain stop date by DCI;

if wks(p,q)>=0 & cwks(p,q)=0 & yme(p,q)>0 then do;
if 0<=mos(p,q)<=me(p,q) then do;
yms(p,q)=(ye(p,q)*100)+01;
yme(p,q)=(ye(p,q)*100)+01+mos(p,q);
end;
do k=1 to 13;
if me(p,q)>=0 & (me(p,q)+(k*12)-11)<=mos(p,q)<=(me(p,q)+(k*12)) then do;
yms(p,q)=((ye(p,q)-k)*100)+01;
if 0<=mos(p,q)<=(k*12) then yme(p,q)=((ye(p,q)-1)*100)+01+mos(p,q)-(k*12)+12;
if mos(p,q)>=((k*12)+1) then yme(p,q)= (ye(p,q)*100) +01+mos(p,q)-(k*12);
end;
end;
if yme(p,q)>iym then yme(p,q)=iym;
end;

if wks(p,q)>=0 & cwks(p,q)=0 & yme(p,q)<=0 then do;
if 0<=mos(p,q)<=intm then do;
yms(p,q)=(inty*100)+01;
yme(p,q)=(inty*100)+01+mos(p,q);
end;
do k=1 to 13;
if (intm+(k*12)-11)<=mos(p,q)<=(intm+(k*12)) then do;
yms(p,q)=((inty-k)*100)+01;
if 0<=mos(p,q)<=(k*12) then yme(p,q)=((inty-1)*100)+01+mos(p,q)-(k*12)+12;
if mos(p,q)>=((k*12)+1) then yme(p,q)= (inty*100) +01+mos(p,q)-(k*12);
end;
end;
end;


efl(p,q)=3;

end;


* If stop date is known but start date is not, then set DLI as start date;
if yme(p,q)>0 and yms(p,q)=. then do;
yms(p,q)=dliym;
if q=1 or q=((dim(csm,2)/2)+1) then efl(p,q)=3;
else if 2<=q<=(dim(csm,2)/2) or ((dim(csm,2)/2)+2)<=q<=dim(csm,2) then efl(p,q)=7;
end;


** (4) If stop year is known but stop month is not known;

if yms(p,q)>0 and ye(p,q)>0 and -2<=me(p,q)<=-1 then do;

* If weeks are known, then count forward from start date. If the number of months falls
short of the stop year, then use Jan of the end year as the stop date. If the number of
months exceeds the stop year, then use Dec of the end year as the stop date. Constrain
stop date by DCI;
if wks(p,q)>=0 then do;
nms(p,q)=yms(p,q)-round(yms(p,q),100);
if 0<=mos(p,q)<=(12-nms(p,q)) then yme(p,q)=yms(p,q)+mos(p,q);
do k=1 to 13;
A=(k*88);
if ((k*12)+1-nms(p,q))<=mos(p,q)<=((k*12)+12-nms(p,q)) then yme(p,q)=yms(p,q)+A+mos(p,q);
end;
if yme(p,q)>((ye(p,q)*100)+12) then yme(p,q)=((ye(p,q)*100)+12);
if yme(p,q)<((ye(p,q)*100)+01) then yme(p,q)=((ye(p,q)*100)+01);
if yme(p,q)>iym then yme(p,q)=iym;
end;

* If weeks are missing then set end date to Dec of stop year and constrain by DCI;
if -3<=wks(p,q)<0 then yme(p,q)=((ye(p,q)*100)+12);
if yme(p,q)>iym then yme(p,q)=iym;

if (efl(p,q) not in (2,3,7) or efl(p,q)=.) then efl(p,q)=4;
if efl(p,q) in (2,3,7) then efl(p,q)=6;

end;


** (5) If stop year is unknown;

if -3<=ye(p,q)<=-1 then do;

* If weeks are known then count forward from start date;
if yms(p,q)>0 and wks(p,q)>=0 then do;
nms(p,q)=yms(p,q)-round(yms(p,q),100);
if 0<=mos(p,q)<=(12-nms(p,q)) then yme(p,q)=yms(p,q)+mos(p,q);
do k=1 to 13;
A=(k*88);
if ((k*12)+1-nms(p,q))<=mos(p,q)<=((k*12)+12-nms(p,q)) then yme(p,q)=yms(p,q)+A+mos(p,q);
end;
if yme(p,q)>iym then yme(p,q)=iym;
end;

* If weeks are missing then set Dec of start year as stop date and constrain by DCI;
if yms(p,q)>0 and -3<=wks(p,q)<0 then yme(p,q)=(round(yms(p,q),100))+12;
if yme(p,q)>iym then yme(p,q)=iym;

if (efl(p,q) not in (2,3,7) or efl(p,q)=.) then efl(p,q)=5;
if efl(p,q) in (2,3,7) then efl(p,q)=6;
end;


** (6) If the start and stop years are unknown and the weeks are unknown, use DLI and DCI as
start and stop dates, respectively.;

if -3<=ys(p,q)<=-1 and -3<=ye(p,q)<=-1 and cwks(p,q)=0 and -3<=wks(p,q)<0 then do;
yme(p,q)=iym;
yms(p,q)=dliym;

if q=1 or q=((dim(csm,2)/2)+1) then efl(p,q)=6;
else if 2<=q<=(dim(csm,2)/2) or ((dim(csm,2)/2)+2)<=q<=dim(csm,2) then efl(p,q)=7;
end;


** Convert start and stop dates of the program spells into cms format;
csm(p,q)=(round(yms(p,q),100)-198000)*.12+(yms(p,q)-round(yms(p,q),100));
cem(p,q)=(round(yme(p,q),100)-198000)*.12+(yme(p,q)-round(yme(p,q),100));


*** Create a variable that determined which person in the household receives the
particular spell of the particular program.;
********************************
** Define the person in the household receiving the program variable. **
** It collapses the answers to 8 categories. The coding is the following - **
** 1=R only **
** 2=spouse/partner only **
** 3=child only **
** 4=R and spouse/partner **
** 5=R and child **
** 6=spouse/partner and child **
** 7=R and spouse/partner and child **
** 8=other **
** The first 7 categories may include an 'other' person as captured by response **
** categories 4 (other relatives in household) and 5 (other (specify)) in the **
** original question. If only 'other' person is listed as receiving, then the **
** 8th answer category is used in the created variable. **
*********************************************;

if rcvr(p,q)=1 and rcvs(p,q)=0 and rcvc(p,q)=0 then who(p,q)=01;
if rcvr(p,q)=0 and rcvs(p,q)=1 and rcvc(p,q)=0 then who(p,q)=02;
if rcvr(p,q)=0 and rcvs(p,q)=0 and rcvc(p,q)=1 then who(p,q)=03;
if rcvr(p,q)=1 and rcvs(p,q)=1 and rcvc(p,q)=0 then who(p,q)=04;
if rcvr(p,q)=1 and rcvs(p,q)=0 and rcvc(p,q)=1 then who(p,q)=05;
if rcvr(p,q)=0 and rcvs(p,q)=1 and rcvc(p,q)=1 then who(p,q)=06;
if rcvr(p,q)=1 and rcvs(p,q)=1 and rcvc(p,q)=1 then who(p,q)=07;
if -3<=rcvr(p,q)<0 then who(p,q)=rcvr(p,q);
if rcvr(p,q)=0 and rcvs(p,q)=0 and rcvc(p,q)=0 and (rcvf(p,q)=1 or rcvo(p,q)=1) then who(p,q)=08;



*** Create a variable that calculates the amount that is received by the household each month
during a particular spell of a particular program.;
******************************************************************************
** Create an estimated amount using the category reported by R. The estimated amount is the          **
** midpoint rounded down. Note that the 12th category for AFDC, FST & OTH lists $1251 as the **
** amount. This amount was chosen since the category is unbounded - the number represents 1        **
** dollar above the lower bound. Similarly the 6th (highest) category for wic is $101, $1                   **
** above the lower bound, $100.                                                                                                     **
*******************************************************************************;

** AFDC;
if p=1 then do;
inc(p,q)=incm(p,q);
if -3<=incm(p,q)<=-1 and 1<=eincm(p,q)<=10 then inc(p,q)=(eincm(p,q)*100)-50;
if -3<=incm(p,q)<=-1 and eincm(p,q)=11 then inc(p,q)=1125;
if -3<=incm(p,q)<=-1 and eincm(p,q)=12 then inc(p,q)=1251;
end;

** WIC;
if p=2 then do;
inc(p,q)=incm(p,q);
if -3<=incm(p,q)<=-1 and 1<=eincm(p,q)<=5 then inc(p,q)=(eincm(p,q)*20)-10;
if -3<=incm(p,q)<=-1 and eincm(p,q)=6 then inc(p,q)=101;
end;

** FST;
if p=3 then do;
inc(p,q)=incm(p,q);
if -3<=incm(p,q)<=-1 and 1<=eincm(p,q)<=10 then inc(p,q)=(eincm(p,q)*100)-50;
if -3<=incm(p,q)<=-1 and eincm(p,q)=11 then inc(p,q)=1125;
if -3<=incm(p,q)<=-1 and eincm(p,q)=12 then inc(p,q)=1251;
end;

** OTH;
if p=4 then do;
inc(p,q)=incm(p,q);
if -3<=incm(p,q)<=-1 and 1<=eincm(p,q)<=10 then inc(p,q)=(eincm(p,q)*100)-50;
if -3<=incm(p,q)<=-1 and eincm(p,q)=11 then inc(p,q)=1125;
if -3<=incm(p,q)<=-1 and eincm(p,q)=12 then inc(p,q)=1251;
end;


if inc(p,q)>-4 then afl(p,q)=0;
if inc(p,q)=-4 then inc(p,q)=.;

** Compute edit flags for dates (efls) for those cases that have not already been computed.;
if efl(p,q)=. and nefl(p,q)~=. then efl(p,q)=nefl(p,q);

end; /** [E2] **/
end; /** [E1] **/

do p=1 to 4;
do q=1 to dim(csm,2);
tcsm(p,q)=csm(p,q); tcem(p,q)=cem(p,q);
twho(p,q)=who(p,q); tinc(p,q)=inc(p,q);
tefl(p,q)=efl(p,q); tafl(p,q)=afl(p,q);
end;
end;

*** Handedits - 1;
*************;

** R reports receiving, but doesn't know whether stopped for more than a month and so we do not have
any information on stop date. We then handedit these cases on a case-by-case basis.;
do p=1 to 4;
do q=1 to dim(csm,2);
if -3<=stpgp(p,q)<=-1 then do;
HE=HE+1; dtps1=1; dtp1(p)=1;
end;
if -3<=cur(p,q)<=-1 or -3<=cwks(p,q)<=-1 then do;
HE=HE+1; dtps1=2; dtp1(p)=2;
end;
end;
end;

** When Rs report overlapping spells with amount receiving and person receiving are the same for these
spells we just merge all the consecutive spells into 1.;
do p=1 to 4;
do q=4,3,2,8,7,6;
if 0<tcsm(p,q)<=tcem(p,q-1) & tefl(p,q)=1 & tefl(p,q-1)=1
& ((tinc(p,q)=tinc(p,q-1) & tinc(p,q)>=0)|(tinc(p,q)<0 & tinc(p,q-1)<0))
& ((twho(p,q)=twho(p,q-1) & twho(p,q)>=0)|(twho(p,q)<0 & twho(p,q-1)<0))
then do;
HE=HE+1;
dtps2=1;
if dtp2(p)~=-1 then dtp2(p)=1;
if efl(p,q)>1 then dtp2(p)=-1;
dtp22(p,q)=1; dtp22(p,q-1)=1;
csm(p,q)=tcsm(p,q); cem(p,q)=tcem(p,q);
who(p,q)=twho(p,q); inc(p,q)=tinc(p,q);
efl(p,q)=tefl(p,q); afl(p,q)=tafl(p,q);
if 0<tcsm(p,q)<tcsm(p,q-1) then csm(p,q-1)=tcsm(p,q);
if 0<tcem(p,q-1)<tcem(p,q) then cem(p,q-1)=tcem(p,q);
csm(p,q)=.;
cem(p,q)=.;
inc(p,q)=.;
who(p,q)=.;
efl(p,q)=.;
afl(p,q)=.;
end;
end;
end;

** When Rs report overlapping spells being received by different persons it means these are two legit.
spells and so should be counted separately. Our program will however overwrite the earlier spell amt.
by the latter spell amt. for the overlapping months. To correct for that we have to handedit.;
do p=1 to 4;
do q=2 to (dim(csm,2)/2);
if 0<csm(p,q)<=cem(p,q-1) & efl(p,q)=1 & efl(p,q-1)=1 & who(p,q)~=who(p,q-1) then do;
HE=HE+1;
prgerr=1;
whodf(p)=1;
end;
end;
do q=(dim(csm,2)/2)+2 to dim(csm,2);
if 0<csm(p,q)<=cem(p,q-1) & efl(p,q)=1 & efl(p,q-1)=1 & who(p,q)~=who(p,q-1) then do;
HE=HE+1;
prgerr=1;
whodf(p)=2;
end;
end;
end;


** When Rs report overlapping spells with amount receiving different and same person receiving for these
spells we put -3 for all the monthly variables as we cannot decide which of the two values to put and
when one spell ended and the other started. Identify these cases and then handedit them. Initially
put the monthly received variables to 9 (that is necessary for the program to work) and then later
change these to -3.;
do p=1 to 4;
do q=4,3,2,8,7,6;
if 0<tcsm(p,q)<=tcem(p,q-1) & tefl(p,q)=1 & tefl(p,q-1)=1 & twho(p,q)=twho(p,q-1)
& ((tinc(p,q)~=tinc(p,q-1) & tinc(p,q)>=0)|(tinc(p,q)>=0 & tinc(p,q-1)<0)|(tinc(p,q)<0 & tinc(p,q-1)>=0))
then do;
HE=HE+1;
dtps3=1;
if dtp3(p)~=-1 then dtp3(p)=1;
if efl(p,q)>1 then dtp3(p)=-1;
dtp33(p,q)=1; dtp33(p,q-1)=1;
csm(p,q)=tcsm(p,q); cem(p,q)=tcem(p,q);
who(p,q)=twho(p,q); inc(p,q)=tinc(p,q);
efl(p,q)=tefl(p,q); afl(p,q)=tafl(p,q);
if 0<tcsm(p,q-1)<tcsm(p,q) then csm(p,q)=tcsm(p,q-1);
if 0<tcem(p,q)<tcem(p,q-1) then cem(p,q)=tcem(p,q-1);
efl(p,q)=9;
inc(p,q)=-3;
afl(p,q)=-3;
who(p,q)=-3;
csm(p,q-1)=.;
cem(p,q-1)=.;
efl(p,q-1)=.;
inc(p,q-1)=.;
afl(p,q-1)=.;
who(p,q-1)=.;
end;
end;
end;


** Rs report receiving, currently not receiving and no periods of 1 month or more when they did
not receive. So we take this to be receiving till less than a month before the interview.;
do p=1 to 4;
do q=1 to dim(csm,2);
if (cur(p,q)=0|cwks(p,q)=0) & stpgp(p,q)=0 then do;
HE=HE+1;
dtps4=1;
if dtp4(p)~=-1 then dtp4(p)=1;
if efl(p,q)>1 then dtp4(p)=-1;
cem(p,q)=doicm-1;
efl(p,q)=1;
end;
end;
end;

** Rs report currently receiving, a period of 1 month or more when they did not receive, have a valid
stop date but when asked if they received again, said NO so did not go through the second loop. We
create another loop from the month after the reported stop month to DCI, and put efl=7, inc=-3
and who=-3. IF THE STOP DATE IS DCI, THEN WE DO NOT HANDEDIT.;

do p=1 to 4;
do q=1 to dim(csm,2)-1;
if q~=dim(csm,2)/2 & (cur(p,q)=1|cwks(p,q)=1) & stpgp(p,q)=1 & ye(p,q)>0 & me(p,q)>0 & recag(p,q)=0
& cem(p,q)~=doicm then do;
HE=HE+1;
dtps5=1;
if dtp5(p)~=-1 then dtp5(p)=1;
if efl(p,q)>1 then dtp5(p)=-1;
csm(p,q+1)=tcem(p,q)+1;
cem(p,q+1)=doicm;
efl(p,q+1)=7;
afl(p,q+1)=-3;
inc(p,q+1)=-3;
who(p,q+1)=-3;
end;
end;
do q=dim(csm,2), dim(csm,2)/2; * Identify these cases and then add another spell.;
if (cur(p,q)=1|cwks(p,q)=1) & stpgp(p,q)=1 & ye(p,q)>0 & me(p,q)>0 & recag(p,q)=0
& cem(p,q)~=doicm then do;
HE=HE+1;
dtps5=1;
if dtp5(p)~=-2 then dtp5(p)=2;
if efl(p,q)>1 then dtp5(p)=-2;
end;
end;
end;


** If R reports a valid stop date but is not asked whether receives again then handedit similar to cases
of dtps5. As for dtps5 cases we do not handedit if stop date reported is DCI.;
do p=1 to 4;
do q=1 to dim(csm,2)-1;
if q~=dim(csm,2)/2 & ((ys(p,q)>0 & ms(p,q)>0)|dli(p,q)=1) & ye(p,q)>0 & me(p,q)>0 & recag(p,q)=-4
& cem(p,q)~=doicm then do;
HE=HE+1;
dtps6=1;
if dtp6(p)~=-1 then dtp6(p)=1;
if efl(p,q)>1 then dtp6(p)=-1;
csm(p,q+1)=tcem(p,q)+1;
cem(p,q+1)=doicm;
efl(p,q+1)=7;
inc(p,q+1)=-3;
afl(p,q+1)=-3;
who(p,q+1)=-3;
end;
end;
do q=dim(csm,2),dim(csm,2)/2; * Identify these cases and then add another spell.;
if ((ys(p,q)>0 & ms(p,q)>0)|dli(p,q)=1) & (ye(p,q)>0 & me(p,q)>0) & recag(p,q)=-4
& cem(p,q)~=doicm then do;
HE=HE+1;
dtps6=1;
if dtp6(p)~=-2 then dtp6(p)=2;
if efl(p,q)>1 then dtp6(p)=-2;
end;
end;
end;

** Rs went through the NVPR section even though they had reported receiving that program in earlier
rounds. Last time we curtailed the start dates if they were before DLI to DLI. This time I am not
sure we should do that. In a later section (dtps7) we will anyway take care of not counting the
months before DLI.;
do p=1 to 4;
do q=(dim(csm,2)/2)+1 to dim(csm,2);
if inc(p,q)>-4 and ocsm(p)~=. then do;
HE=HE+1;
dtps7=1;
if dtp7(p)~=-1 then dtp7(p)=1;
if efl(p,q)>1 then dtp7(p)=-1;
end;
end;
end;


*** Create the monthly array variables - those that indicate whether R received any of the four govt.
programs in a particular month and the monthly amount received from all these programs.;
c=0;
do l=1 to doicm; /** [B3] **/
c=c+1;
do q=1 to dim(csm,2); /** [B4] **/


** AFDC;
if 0<csm(1,q)<=c<=cem(1,q) then do;
AREC(l)=efl(1,q);
AHHM(l)=who(1,q);
AAMT(l)=inc(1,q);
aod=0;
if AAMT(l)>1000 then aod=AAMT(l);
if AREC(l)>0 and (AAMT(l)=. or AHHM(l)=.) then do;
ackr=ackr+1;
end;
if (AAMT(l)>0 or -3<=AAMT(l)<0) and (AREC(l)=0 or AHHM(l)=.) then do;
acka=acka+1;
end;
if AHHM(l)>0 and (AREC(l)=0 or AAMT(l)=.) then do;
ackh=ackh+1;
end;
if AREC(l)=-3 and (AHHM(l)~=-3 or AAMT(l)~=-3) then do;
ackv=ackv+1;
end;
if AAMT(l)=0 then dummya=1;
end;


** WIC;
if 0<csm(2,q)<=c<=cem(2,q) then do;
WREC(l)=efl(2,q);
WHHM(l)=who(2,q);
WAMT(l)=inc(2,q);
wod=0;
if WAMT(l)>1000 then wod=WAMT(l);
if WREC(l)>0 and (WAMT(l)=. or WHHM(l)=.) then do;
wckr=wckr+1;
end;
if (WAMT(l)>0 or -3<=WAMT(l)<0) and (WREC(l)=0 or WHHM(l)=.) then do;
wcka=wcka+1;
end;
if WHHM(l)>0 and (WREC(l)=0 or WAMT(l)=.) then do;
wckh=wckh+1;
end;
if WREC(l)=-3 and (WHHM(l)~=-3 or WAMT(l)~=-3) then do;
wckv=wckv+1;
end;
if WAMT(l)=0 then dummyw=1;
end;


** FST;
if 0<csm(3,q)<=c<=cem(3,q) then do;
FREC(l)=efl(3,q);
FHHM(l)=who(3,q);
FAMT(l)=inc(3,q);
fod=0;
if FAMT(l)>1000 then fod=FAMT(l);
if FREC(l)>0 and (FAMT(l)=. or FHHM(l)=.) then do;
fckr=fckr+1;
end;
if (FAMT(l)>0 or -3<=FAMT(l)<0) and (FREC(l)=0 or FHHM(l)=.) then do;
fcka=fcka+1;
end;
if FHHM(l)>0 and (FREC(l)=0 or FAMT(l)=.) then do;
fckh=fckh+1;
end;
if FREC(l)=-3 and (FHHM(l)~=-3 or FAMT(l)~=-3) then do;
fckv=fckv+1;
end;
* This fixes a problem in round 3;
if FHHM(l)=. and FREC(l)>0 and FAMT(l)~=. then do;
FHHM(l)=-3;
fckneg=1;
end;
if FAMT(l)=0 then dummyf=1;
end;


** OTH;
if 0<csm(4,q)<=c<=cem(4,q) then do;
OREC(l)=efl(4,q);
OHHM(l)=who(4,q);
OAMT(l)=inc(4,q);
ood=0;
if OAMT(l)>1000 then ood=OAMT(l);
if OREC(l)>0 and (OAMT(l)=. or OHHM(l)=.) then do;
ockr=ockr+1;
end;
if (OAMT(l)>0 or -3<=OAMT(l)<0) and (OREC(l)=0 or OHHM(l)=.) then do;
ocka=ocka+1;
end;
if OHHM(l)>0 and (OREC(l)=0 or OAMT(l)=.) then do;
ockh=ockh+1;
end;
if OREC(l)=-3 and (OHHM(l)~=-3 or OAMT(l)~=-3) then do;
ockv=ockv+1;
end;
if OAMT(l)=0 then dummyo=1;
end;


end; /** [E4] **/
end; /** [E3] **/


*** Handedits - 2;

** R reported receiving in months prior to DLI. We delete any information in the monthly variables till
DLI i.e receiving variables are 0, amount and person receiving variables are missing.;
do p=1 to 4;
do q=1 to dim(csm,2);
if 0<csm(p,q)<=cdli then do;
HE=HE+1;
dtps8=1;
if dtp8(p)~=-1 then dtp8(p)=1;
if efl(p,q)>1 then dtp8(p)=-1;
C=0;
do l=1 to dim(AREC);
C=C+1;
if csm(p,q)<=C<=cdli then do;
ALLREC(p,l)=0;
ALLAMT(p,l)=.;
ALLHHM(p,l)=.;
end;
end;
end;
end;
end;


if GPEV>-4 then do;
*** Adjust amount variables if they appear to be too high - then we assume that Rs have reported the
whole amount that they received instead of the average monthly amount.;

** Compute aodttl, wodttl, fodttl and oodttl.;
do l=1 to dim(AREC);
if AREC(l)>0 and AAMT(l)>1000 and aod>0 then do;
aodttl=aodttl+1;
end;
if FREC(l)>0 and FAMT(l)>1000 and fod>0 then do;
fodttl=fodttl+1;
end;
if OREC(l)>0 and OAMT(l)>1000 and ood>0 then do;
oodttl=oodttl+1;
end;
if WREC(l)>0 and WAMT(l)>1000 and wod>0 then do;
wodttl=wodttl+1;
end;
end;


** Divide the problematic "too high" amount by the total number of months receiving these amounts.;
do l=1 to dim(AREC);
if AAMT(l)>1000 and aodttl>0 and AREC(l)>0 then do;
AAMT(l)=round(AAMT(l)/aodttl, 1);
end;
if WAMT(l)>1000 and wodttl>0 and WREC(l)>0 then do;
WAMT(l)=round(WAMT(l)/wodttl, 1);
end;
if FAMT(l)>1000 and fodttl>0 and FREC(l)>0 then do;
FAMT(l)=round(FAMT(l)/fodttl, 1);
end;
if OAMT(l)>1000 and oodttl>0 and OREC(l)>0 then do;
OAMT(l)=round(OAMT(l)/oodttl, 1);
end;
end;


*** Compute mxx, amtxx and ttlg - months receiving in each year (mxx), the amount receiving in each
year (amtxx) and the total number of months received ever (ttlg);
do j=1 to dim(GPRTTL);
gm(j)=0;
ttlg=0;
gamt(j)=0;
ga(j)=0;
gn(j)=0;
end;
do j=1 to dim(GPRTTL);
do l=((j*12)-11) to (j*12);
if gm(j)>=0 and (AREC(l)>0 or WREC(l)>0 or FREC(l)>0 or OREC(l)>0) then do;
gm(j)=gm(j)+1;
end;
if AREC(l)>1 then gm(j)=-3;
if WREC(l)>1 then gm(j)=-3;
if FREC(l)>1 then gm(j)=-3;
if OREC(l)>1 then gm(j)=-3;
do p=1 to 4;
if -3<=ALLAMT(p,l)<=-1 then do;
gn(j)=gn(j)+1;
gamt(j)=ALLAMT(p,l);
end;
if ALLAMT(p,l)>=0 then do;
ga(j)=ga(j)+1;
if ga(j)=1 and gn(j)=0 then gamt(j)=ALLAMT(p,l);
if ga(j)>1 and gn(j)=0 then gamt(j)=gamt(j)+ALLAMT(p,l);
if gm(j)=-3 then gamt(j)=-3;
end;
end;
end;
end;
do l=1 to dim(AREC);
if ttlg>=0 and (AREC(l)=1 or WREC(l)=1 or FREC(l)=1 or OREC(l)=1) then do;
ttlg=ttlg+1;
end;
if AREC(l)>1 or AREC(l)=-3 then ttlg=-3;
if WREC(l)>1 or WREC(l)=-3 then ttlg=-3;
if FREC(l)>1 or FREC(l)=-3 then ttlg=-3;
if OREC(l)>1 or OREC(l)=-3 then ttlg=-3;
end;

end;

*** Handedits - 3;
** Reconverting monthly receiving variables from 9 to -3.;
do p=1 to 4;
do l=1 to dim(AREC);
if ALLREC(p,l)=9 then ALLREC(p,l)=-3;
end;
end;

** We put back the original start and stop dates, edit flags for dates and amounts of overlapping spells
which we had changed for computing purposes (see dtps2 and dtps3).;
do p=1 to 4;
do q=1 to dim(csm,2);
if (dtp22(p,q)=1|dtp33(p,q)=1) then do;
csm(p,q)=tcsm(p,q);
cem(p,q)=tcem(p,q);
inc(p,q)=tinc(p,q);
who(p,q)=twho(p,q);
efl(p,q)=tefl(p,q);
afl(p,q)=tafl(p,q);
end;
end;
end;

** Adding the amounts received by the other person in the earlier spell - follow-up from prgerr in
Handedit1 section.;


**************************** PART IV ****************************
** Create the final variables by combining information from this and earlier rounds. **
*****************************************************************;

*** Calculate the total number of months ever received (GPEV).;
if ttlg>=0 and GPEV>=0 then GPEV=ttlg+GPEV;
if ttlg in (-1,-2,-3) or GPEV in (-1,-2-3) then GPEV=-3;


*** Calculate the total number of months received in each year (GIRTTLXX) and the total amount
receiving in each year (GPATTLXX).;
do j=1 to dim(GPRTTL);
if gm(j)>=0 and GPRTTL(j)>=0 then do;
GPRTTL(j)=gm(j)+GPRTTL(j);
end;
if gm(j)<0 or GPRTTL(j)<0 then GPRTTL(j)=-3;
if gamt(j)>=0 and GPATTL(j)>=0 then do;
GPATTL(j)=gamt(j)+GPATTL(j);
end;
if gamt(j)<0 or GPATTL(j)<0 or (GPRTTL(j)<0 and GPRTTL(j)~=-4) then GPATTL(j)=-3;
if gamt(j)=0 and ogpattl(j)=-4 and GPRTTL(j)=0 then GPATTL(j)=-4;
end;



*** To change all invalid skips to -3;

array vars GPEV GPRTTL80-GPRTTL99 GPRTTL00 GPRTTL01-GPRTTL05
GPATTL80-GPATTL99 GPATTL00 GPATTL01-GPATTL05;

do over vars;
if vars=-2 then vars=-3;
if vars=-1 then vars=-3;
end;

ENDSAS;

Return to top


Unemployment Compensation

Variables Created:

Variables Used

The input variables are listed in a separate file.

This program creates several variables describing the respondent's receipt of unemployment compensation:

  1. CV_UI_YR.XX - indicates the number of months in any given year (from 1980 to 2005) that R received Unemployment Compensation.
  2. CV_UI_EVER - indicates the total number of months (from 1980 to 2005) that R received Unemployment Compensation.
  3. CV_AMT_UI_YR.XX - indicates the amount of Unemployment Compensation received in any given year (from 1980 to 2005) by R.
  4. CV_UI_SPELLS_YR.XX - indicates the number of spells of Unemployment Compensation that R received started in any given year (from 1980 to 2005).

The program first creates a month-by-month participation array for unemployment compensation.  These month-by-month variables constitute part of the event history array for program participation; see appendix 7 for more information.  After the array is created, the program merges data to create the summary variables. 


** Note: Abbreviations used in this program are as follows:
DLI - Date of last interview
DCI - Date of current interview
SDLI - Since date of last interview
NVPR - Never prior - NVPR
CMS - Continuous month scheme
UNEMP - Unemployment Compensation.;


*** All the arrays used in this program.;

** (1) Created Variables - yearly.;
array UIRTTL (26) UIRTTL80-UIRTTL99 UIRTTL00 UIRTTL01-UIRTTL05;
array UIATTL (26) UIATTL80-UIATTL99 UIATTL00 UIATTL01-UIATTL05;
array UISPLS (26) UISPLS80-UISPLS99 UISPLS00 UISPLS01-UISPLS05;

** (2) Interview dates of prior rounds.;
array intdR (7) intdR1-intdR7; * interview day.;
array intmR (7) intmR1-intmR7; * interview month.;
array intyR (7) intyR1-intyR7; * interview year.;


** (3) Created variables of prior rounds.;
array uievR (7) uievR1-uievR7; * no. of months ever received.;
* no. of months received in a given year.;
array uirttlR (7,26) uir1ttl80-uir1ttl99 uir1ttl00 uir1ttl01-uir1ttl05
uir2ttl80-uir2ttl99 uir2ttl00 uir2ttl01-uir2ttl05
uir3ttl80-uir3ttl99 uir3ttl00 uir3ttl01-uir3ttl05
uir4ttl80-uir4ttl99 uir4ttl00 uir4ttl01-uir4ttl05
uir5ttl80-uir5ttl99 uir5ttl00 uir5ttl01-uir5ttl05
uir6ttl80-uir6ttl99 uir6ttl00 uir6ttl01-uir6ttl05
uir7ttl80-uir7ttl99 uir7ttl00 uir7ttl01-uir7ttl05;
* amount received in a given year.;
array uiattlR (7,26) uia1ttl80-uia1ttl99 uia1ttl00 uia1ttl01-uia1ttl05
uia2ttl80-uia2ttl99 uia2ttl00 uia2ttl01-uia2ttl05
uia3ttl80-uia3ttl99 uia3ttl00 uia3ttl01-uia3ttl05
uia4ttl80-uia4ttl99 uia4ttl00 uia4ttl01-uia4ttl05
uia5ttl80-uia5ttl99 uia5ttl00 uia5ttl01-uia5ttl05
uia6ttl80-uia6ttl99 uia6ttl00 uia6ttl01-uia6ttl05
uia7ttl80-uia7ttl99 uia7ttl00 uia7ttl01-uia7ttl05;
* no. of spells started in a given year.;
array uisplsR (7,26) ui1spls80-ui1spls99 ui1spls00 ui1spls01-ui1spls05
ui2spls80-ui2spls99 ui2spls00 ui2spls01-ui2spls05
ui3spls80-ui3spls99 ui3spls00 ui3spls01-ui3spls05
ui4spls80-ui4spls99 ui4spls00 ui4spls01-ui4spls05
ui5spls80-ui5spls99 ui5spls00 ui5spls01-ui5spls05
ui6spls80-ui6spls99 ui6spls00 ui6spls01-ui6spls05
ui7spls80-ui7spls99 ui7spls00 ui7spls01-ui7spls05;
* start date of each spell.;
array csmR (7,4) csmuR1_1-csmuR1_4
csmuR2_1-csmuR2_4
csmuR3_1-csmuR3_4
csmuR4_1-csmuR4_4
csmuR5_1-csmuR5_4
csmuR6_1-csmuR6_4
csmuR7_1-csmuR7_4;
* start date of each spell.;
array cemR (7,4) cemuR1_1-cemuR1_4
cemuR2_1-cemuR2_4
cemuR3_1-cemuR3_4
cemuR4_1-cemuR4_4
cemuR5_1-cemuR5_4
cemuR6_1-cemuR6_4
cemuR7_1-cemuR7_4;
* edit flag for dates for each spell.;
array eflR (7,4) efluR1_1-efluR1_4
efluR2_1-efluR2_4
efluR3_1-efluR3_4
efluR4_1-efluR4_4
efluR5_1-efluR5_4
efluR6_1-efluR6_4
efluR7_1-efluR7_4;

** (4) Latest created variables available from prior rounds.;
* ouiev; * no. of months ever received.;
array ouirttl (26) ouirttl80-ouirttl99 ouirttl00 ouirttl01-ouirttl05; * no. of months rec., yearly;
array ouiattl (26) ouiattl80-ouiattl99 ouiattl00 ouiattl01-ouiattl05; * amount recd., yearly;
array ouispls (26) ouispls80-ouispls99 ouispls00 ouispls01-ouispls05; * no. of spells started, yearly.;


** (5) (Raw data) Information available from current round.
The extra loop in these arrays is when we have to impute a new spell for some problem cases
- dataprb4, dataprb5;

* START YEAR, MONTH, ACTUAL DAY and ESTIMATED DAY information.;
array ys (6) ps4000Y1-ps4000Y3 p4000Y1-p4000Y3;
array ms (6) ps4000M1-ps4000M3 p4000M1-p4000M3;
array ds (6) ps42001-ps42003 p42001-p42003;
array es (6) ps43001-ps43003 p43001-p43003;

* END YEAR, MONTH, ACTUAL DAY and ESTIMATED DAY information.;
array ye (6) ps4700Y1-ps4700Y3 p4700Y1-p4700Y3;
array me (6) ps4700M1-ps4700M3 p4700M1-p4700M3;
array de (6) ps49001- ps49003 p49001-p49003;
array ee (6) ps50001- ps50003 p50001-p50003;

* ESTIMATED WEEKS - unable to answer start or stop date questions.;
array wks (6) ps52001-ps52003 p52001-p52003;

* AMOUNT RECEIVED - actual & estimated.;
array incm (6) ps59001-ps59003 p59001-p59003;
array eincm (6) ps60001-ps60003 p60001-p60003;

* STOPPED FOR 2+ WEEKS.;
array stpgp (6) ps45001-ps45003 p45001-p45003;

* RECEIVE AGAIN?;
array recag (6) ps63001-ps63003 p63001-p63003;

* CURRENTLY RECEIVING information:
For NVPR sections:;
array cur (6) ps44001-ps44003 p44001-p44003;
array cwks (6) ps1930 ps1930 ps1930 p3500 p3500 p3500;

* RECEIVING at DLI
Replaced ps1850 by ps39011 as ps1850 was asked of some Rs only. Others were asked ps1899. ps39011
combines all these responses.;
array dli (6) ps39011 dumu2-dumu6;

** (6) Intermediate variables created based on information available from current round.;

array UIREC (312) UIREC001-UIREC312; * indicator for receipt, monthly.;
array UIAMT (312) UIAMT001-UIAMT312; * amount received, monthly.;

* ttlu; * no. of months ever received.;
array um (26) um80-um99 um00 um01-um05; * no. of months received, yearly.;
array uamt (26) uamt80-uamt99 uamt00 uamt01-uamt05; * amount received, yearly.;
array nu (26) nu80-nu99 nu00 nu01-nu05; * no. of spells started, yearly.;
array ua (26) ua80-ua99 ua00 ua01-ua05; * no. of months with valid amounts.;
array un (26) un80-un99 un00 un01-un05; * no. of months with invalid amounts.;

array yms (6) ymsu11-ymsu13 ymsu21-ymsu23; * start date in YYYYMM scheme.;
array csm (6) csmu11-csmu13 csmu21-csmu23; * start date in CMS.;
array yme (6) ymeu11-ymeu13 ymeu21-ymeu23; * stop date in YYYYMM scheme.;
array cem (6) cemu11-cemu13 cemu21-cemu23; * stop date in CMS.;
array sdy (6) sdyu11-sdyu13 sdyu21-sdyu23; * start day.;
array edy (6) edyu11-edyu13 edyu21-edyu23; * stop day.;
array mos (6) mosu11-mosu13 mosu21-mosu23; * estimated months received.;
array nms (6) nmsu11-nmsu13 nmsu21-nmsu23; * start month.;
array inc (6) incu11-incu13 incu21-incu23; * daily amount.;
array afl (6) aflu11-aflu13 aflu21-aflu23; * amount flag.;
array efl (6) eflu11-eflu13 eflu21-eflu23; * date flag.;
array nefl (6) neflu11-neflu13 neflu21-neflu23; * date flag when efl is not computed bcos cem<dlicm;
array agfl (6) agflu11-agflu13 agflu21-agflu23; * age flag.;
array eflC (6) eflCu11-eflCu13 eflCu21-eflCu23; * date flag to be used for checking "efl";
array edli (6) edliu11-edliu13 edliu21-edliu23; * flag for stop date before DLI.;
array ovp (6) ovpu11-ovpu13 ovpu21-ovpu23; * Used for checking for overlapping spells.;
array mon (12) mon1-mon12; * Month no.;
array ndy (12) ndy1-ndy12; * No. of days in the corresponding month.;
array prbefl (7) prbefl1-prbefl7; * To be used for checking efls.;

array tcsm (6) tcsmu11-tcsmu13 tcsmu21-tcsmu23; * start date in CMS.;
array tcem (6) tcemu11-tcemu13 tcemu21-tcemu23; * stop date in CMS.;
array tsdy (6) tsdyu11-tsdyu13 tsdyu21-tsdyu23; * start day.;
array tedy (6) tedyu11-tedyu13 tedyu21-tedyu23; * stop day.;
array tinc (6) tincu11-tincu13 tincu21-tincu23; * daily amount.;
array tafl (6) taflu11-taflu13 taflu21-taflu23; * amount flag.;
array tefl (6) teflu11-teflu13 teflu21-teflu23; * date flag.;

**** Handedits - 1;


****************************************************************************
** Initialize the created variables at the value at DLI. Create date of birth, DCI, DLI etc. in CMS **
** and YYYYMM schemes.                                                                                                       **
****************************************************************************

** Identify the last round that R was interviewed (dli_rnd);
do i=1 to dim(intmR);
if intmR(i)~=-5 then dli_rnd=i;
end;

** Intialize values of UIRTTL (& ouirttl), UIATTL (& ouiattl), UISPLS (& ouispls), UIEV (& ouiev),
ocsmu, ocemu and oeflu by their values at the DLI;
do i=1 to dim(intmR);
if dli_rnd=i then do;
UIEV=uievR(i);
ouiev=uievR(i);
do j=1 to dim(UIRTTL);
UIRTTL(j)=uirttlR(i,j);
UIATTL(j)=uiattlR(i,j);
UISPLS(j)=uisplsR(i,j);
ouirttl(j)=UIRTTL(j);
ouiattl(j)=UIATTL(j);
ouispls(j)=UISPLS(j);
end;
end;
end;

** Identify the start and stop dates and edit flag for those dates for the last spell reported in prior
rounds - ocsmu, ocemu and oeflu.;
do i=1 to dim(csmR,1);
do t=1 to dim(csmR,2);
if csmR(i,t)>-4 then do;
ocsmu=csmR(i,t);
ocemu=cemR(i,t);
oeflu=eflR(i,t);
end;
end;
end;

** Take care of cases in earlier rounds;
do j=1 to dim(UIRTTL);
if UIRTTL(j)=. or UIRTTL(j)=-4 then do;
ouirttl(j)=-4;
UIRTTL(j)=0;
end;
if UIATTL(j)=. or UIATTL(j)=-4 then do;
ouiattl(j)=-4;
UIATTL(j)=0;
end;
if UISPLS(j)=. or UISPLS(j)=-4 then do;
ouispls(j)=-4;
UISPLS(j)=0;
end;
end;
if UIEV=. or UIEV=-4 then do;
UIEV=0;
ouiev=-4;
end;

** Create various important date variables in the two schemes - the YYYYMM scheme and the continuous
month scheme (CMS)
ymb - Date of Birth in YYYYMM scheme
cmb - Date of Birth in CMS
ym14 - Date of 14th birthday in YYYYMM scheme
cm14 - Date of 14th birthday in CMS
dliym - month after DLI in YYYYMM scheme
dlicm - month after DLI in CMS
cdli - DLI in CMS
iym - DCI in YYYYMM scheme
doicm - DCI in CMS
mnthaf - month after CDI
aaiym - Age at DCI in YYYYMM scheme
aaicm - Age at DCI in CMS;

ymb=(doby*100)+dobm;
cmb=((doby-1980)*12)+dobm;
ym14=ymb+1400;
cm14=cmb+(14*12);

if inty>0 and intm>0 then do;
iym=(inty*100)+intm;
doicm=((inty-1980)*12)+intm;
mnthaf=doicm+1;
aaiym=iym-ymb;
aaicm=doicm-cmb;
end;

if inty in (-1,-2,-3) or intm in (-1,-2,-3) then do;
iym=-3;
doicm=-3;
aaiym=-3;
aaicm=-3;
end;

do z=1 to 12;
mon(z)=z;
end;

do z=1 to 12;
if mon(z) in (1,3,5,7,8,10,12) then ndy(z)=31;
if mon(z)=2 then ndy(z)=28;
if mon(z) in (4,6,9,11) then ndy(z)=30;
end;

** Create variables pertaining to the DLI;
if p1210=1 then do;
do i=1 to dim(intmR);
if i=dli_rnd then do;
if intmR(i)<12 then dliym=(intyR(i)*100)+(intmR(i)+1);
if intmR(i)=12 then dliym=((intyR(i)+1)*100)+1;
dlicm=((intyR(i)-1980)*12)+(intmR(i)+1);
cdli=((intyR(i)-1980)*12)+intmR(i);
dli_d=intdR(i);
dli_m=dliym-round(dliym,100);
dli_y=round(dliym,100)/100;
end;
end;
end;

if p1210~=1 then do;
dliym=ym14;
dli_d=dobd;
dli_m=dobm;
dli_y=doby+14;
dlicm=cm14;
cdli=cm14-1;
end;

do z=1 to 12;
if dli_m=mon(z) then ddliday=ndy(z)+1-dli_d;
end;

if dli_m=1 or dli_m=8 then do;
dliday=(31-dli_d+31);
dliday1=31-dli_d;
dliday2=31;
end;
if dli_m=3 then do;
dliday=(28-dli_d+31);
dliday1=28-dli_d;
dliday2=31;
end;
if dli_m in (5,7,10,12) then do;
dliday=(30-dli_d+31);
dliday1=30-dli_d;
dliday2=31;
end;
if dli_m in (4,6,9,11) then do;
dliday=(31-dli_d+30);
dliday1=31-dli_d;
dliday2=30;
end;
if dli_m=2 then do;
dliday=(31-dli_d+28);
dliday1=31-dli_d;
dliday2=28;
end;

**********************************************
** Create variables using informaiton from current round. **
**********************************************;

** Change weekly amount received from UNEMP figures to daily figures.;
do p=1 to dim(csm);
if incm(p)>0 then inc(p)=incm(p)/7;
if incm(p)<=0 then inc(p)=incm(p);
end;

** Initialize all UIREC from the date of birth to DCI to zero.;
do l=cmb to doicm;
UIREC(l)=0;
end;

** Initialize the following counters to zero. ;
uickr=0; * Counter=1 when UIREC>0 but UIAMT is missing;
uicka=0; * Counter=1 when UIAMT is not missing (>=0 or -3) but UIREC=0;
uickv=0; * Counter=1 when UIREC is invalid but UIAMT not invalid;
uiodttl=0; * Counter for total number of months received the problematic amounts;
samemth=0; * Dummy indicator for spells starting and ending in the same months;


***************************************************************************
** Define the start date and end dates. If R reports still receiving, then use DCI as the temporary  **
** end date for the last loop reported. In the next survey round, R will be asked if he or she is      **
** still receiving. If not, then a permanent end date equivalent to the interview date of the last        **
** round will be assigned. If start or end dates are missing, impute those dates. Users will be able **
** to tell what was imputed by looking at the following participation flag variable created during    **
** the program. The categories are the following:                                                                         **
** 1=R reported participation dates                                                                                             **
** 2=start month imputed                                                                                                            **
** 3=start month and year imputed                                                                                              **
** 4=stop month imputed                                                                                                            **
** 5=stop month and year imputed                                                                                              **
** 6=start and stop dates imputed                                                                                               **
** 7=err_or in data due to round 8 questionnaire problems or inconsistent response.                    **
** Both results in our not sure whether Rs received in these months or not.                                   **
** QUESTIONNAIRE ERR_OR: These Rs reported valid start and stop dates but were never   **
** asked the follow-up question - if they received again.                                                               **
** CONFLICTING RESPONSE: These Rs reported currently receiving, a valid start date          **
** and a valid stop date that is different from the DCI but in                                                         **
** the follow-up question as to whether they received again,                                                        **
** they answered NO.                                                                                                                **
***************************************************************************;

**** Create start and stop dates of welfare spells - format yyyymm;

** The start and or end days are missing. So we have to make some assumptions about them. We assume
the start day to be the 1st of the month and the end day to be the last day of the month.;
do p=1 to dim(csm);
if -4<es(p)<0 then do;
dataprb1=1;
handedit=handedit+1;
sdy(p)=28;
end;
if -4<ee(p)<0 then do;
dataprb1=1;
handedit=handedit+1;
edy(p)=28;
end;
end;

do p=1 to dim(csm); /** [B1] **/

*** (1) Set start date if both start month and year are valid;
if ys(p)>0 and ms(p)>0 then do;
yms(p)=(ys(p)*100)+ms(p);

** Set start day, if given.;
if ds(p)>0 or es(p)>0 then do;
if ms(p) in (1,3,5,7,8,10,12) then do;
if ds(p)>0 and ds(p)~=. then sdy(p)=(32-ds(p));
if es(p)=1 then sdy(p)=31;
if es(p)=2 then sdy(p)=21;
if es(p)=3 then sdy(p)=11;
end;
if ms(p) in (4,6,9,11) then do;
if ds(p)>0 and ds(p)~=. then sdy(p)=(31-ds(p));
if es(p)=1 then sdy(p)=30;
if es(p)=2 then sdy(p)=20;
if es(p)=3 then sdy(p)=10;
end;
if ms(p)=2 then do;
if ds(p)>0 and ds(p)~=. then sdy(p)=(29-ds(p));
if es(p)=1 then sdy(p)=28;
if es(p)=2 then sdy(p)=18;
if es(p)=3 then sdy(p)=8;
end;
end;
end;

** Set start date to DLI if receiving at DLI.;
if dli(p)=1 then do;
yms(p)=dliym;
sdy(p)=dliday;
if ps1930=1 then do;
yme(p)=iym;
edy(p)=intd;
nogaps=1;
end;
end;

** Set end date to DCI if receiving now.;
if cur(p)=1 then do;
yme(p)=iym;
edy(p)=intd;
end;

** Set end date if both end month and year are valid.;
if ye(p)>0 and me(p)>0 then do;
yme(p)=(ye(p)*100)+me(p);
* set end day, if given.;
if de(p)>0 and de(p)~=. then do;
edy(p)=de(p);
end;
* end day unknown, estimate given.;
if de(p)<0 and ee(p)>0 and ee(p)~=. then do;
if ee(p)=1 then edy(p)=9;
if ee(p)=2 then edy(p)=19;
if ee(p)=3 then edy(p)=28;
end;
end;

** if end month greater than DCI, constrain by DCI.;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;

if yms(p)>0 and yme(p)>=dliym then efl(p)=1;
if yms(p)>0 and yme(p)<dliym then nefl(p)=1;

** determine months from estimated weeks variable.;
if wks(p)>=0 and (ys(p)<0 or ms(p)<0 or ye(p)<0 or me(p)<0) then do;
mos(p)=floor(wks(p)/4.3);
end;

agfl(p)=0;

if ys(p)>0 and ys(p)<1990 then agfl(p)=1;


*** (2) if start year is known and month is unknown.;
if ys(p)>0 and -3<=ms(p)<=-1 then do;


** If weeks are known and currently receiving, then count backwards by the number of weeks from
DCI. If the number of weeks falls short of the start year, the start month is December of
that year. If the number of weeks is past the start year, then the start month is January of
that year.;
if (wks(p)>=0 and cwks(p)=1) then do;
yme(p)=iym;
edy(p)=intd;
if 0<=mos(p)<=(intm-1) then yms(p)=yme(p)-mos(p);
do k=1 to 13;
A=k*88;
if (intm+(k*12)-12)<=mos(p)<=(intm+(k*12)-1) then yms(p)=yme(p)-A-mos(p);
end;
do z=1 to 12;
if (yms(p)-(round(yms(p), 100)))=mon(z) then sdy(p)=ndy(z);
end;
if yms(p)<((ys(p)*100)+01) then do;
yms(p)=((ys(p)*100)+01);
sdy(p)=31;
end;
if yms(p)<dliym then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;
if yms(p)>((ys(p)*100)+12) then do;
yms(p)=((ys(p)*100)+12);
sdy(p)=31;
end;
end;

** Weeks missing and currently receiving - set end date to DCI and start date to December of
start year and constrain start date by DCI and DLI.;
else if (-3<=wks(p)<0 and cwks(p)=1) then do;
yme(p)=iym;
edy(p)=intd;
yms(p)=((ys(p)*100)+12);
sdy(p)=31;
if yms(p)>iym then do;
yms(p)=iym;
sdy(p)=intd;
end;
if yms(p)<dliym then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;
end;

** Weeks missing and not currently receiving - set start date to January of start year and end
date to December of start year. Constrain start date by DLI and end date by DCI.;
else if (-3<=wks(p)<0 and cwks(p)=0) then do;
yms(p)=((ys(p)*100)+01);
sdy(p)=31;
yme(p)=((ys(p)*100)+12);
edy(p)=31;
if yms(p)<dliym then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;
end;

** If weeks are known and not currently receiving, then count forward by the number of weeks
from January of the start year. Constrain start date by DLI. if the count exceeds DCI then
stop counting at DCI.;
else if (wks(p)>=0 and cwks(p)=0) then do;
yms(p)=((ys(p)*100)+01);
sdy(p)=31;
if yms(p)<dliym then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;
nms(p)=yms(p)- round(yms(p),100);
if 0<=mos(p)<=(12-nms(p)) then yme(p)=yms(p)+mos(p);
do k=1 to 13;
A=k*88;
if ((k*12)+1-nms(p))<=mos(p)<=((k*12)+12-nms(p)) then yme(p)=yms(p)+A+mos(p);
end;
do z=1 to 12;
if (yme(p)-(round(yme(p), 100)))=mon(z) then edy(p)=ndy(z);
end;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;
end;

if yme(p)>0 and wks(p)=-4 then do;
yms(p)=((ys(p)*100)+01);
sdy(p)=31;
end;

if yms(p)<dliym then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;

if yms(p)>((ys(p)*100)+12) then do;
yms(p)=((ys(p)*100)+12);
sdy(p)=31;
end;

efl(p)=2;

end;


*** (3) If start year is unknown.;
if -3<=ys(p)<=-1 then do;

** If currently receiving and weeks are known then count back from DCI.;
if (wks(p)>=0 and cwks(p)=1) then do;
if 0<=mos(p)<=(intm-1) then yms(p)=yme(p)-mos(p);
do k=1 to 13;
A=k*88;
if (intm+(k*12)-12)<=mos(p)<=(intm+(k*12)-1) then yms(p)=yme(p)-A-mos(p);
end;
do z=1 to 12;
if yms(p)-(round(yms(p),100))=mon(z) then sdy(p)=ndy(z);
end;
yme(p)=iym;
edy(p)=intd;
if yms(p)<dliym then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;
end;

** If currently receiving and weeks are unknown then take DLI as start date if this is the first
loop. Otherwise take the month after the stop date for the last spell as the start date. Take
DCI as stop date.;
if (-3<=wks(p)<0 and cwks(p)=1) and (p=1 or p=(dim(csm)/2)+1) then do;
yms(p)=dliym;
yme(p)=iym;
sdy(p)=ddliday;
edy(p)=intd;
end;
if (-3<=wks(p)<0 and cwks(p)=1) and (1<p<=dim(csm)/2 or (dim(csm)/2)+1<p<=dim(csm)) then do;
yms(p)=yme(p-1)+1;
yme(p)=iym;
do z=1 to 12;
if (yms(p)-(round(yms(p), 100)))=mon(z) then sdy(p)=ndy(z);
end;
edy(p)=intd;
end;


** If weeks are known and currently not receiveing, then count back from DCI or stop date if known
to find the most recent year R could have begun receiving. Set start date as January of that
year. Then count forward the number of months from January of that year and set the stop date.
Constrain start and stop dates by DLI and DCI, respectively.;

if wks(p)>=0 and cwks(p)=0 and yme(p)>0 then do;
if 0<=mos(p)<=me(p) then do;
yms(p)=(inty*100)+01;
yme(p)=(ye(p)*100)+01+mos(p);
end;
do k=1 to 13;
if me(p)>=0 & (me(p)+(k*12)-11)<=mos(p)<=(me(p)+(k*12)) then do;
yms(p)=((ye(p)-k)*100)+01;
if 0<=mos(p)<=(k*12) then yme(p)=((ye(p)-1)*100)+01+mos(p)-(k*12)+12;
if mos(p)>=((k*12)+1) then yme(p)= (ye(p)*100) +01+mos(p)-(k*12) ;
end;
end;
sdy(p)=31;
do z=1 to 12;
if (yme(p)-(round(yms(p),100)))=mon(z) then edy(p)=ndy(z);
end;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=de(p);
if ee(p)=1 then edy(p)=9;
if ee(p)=2 then edy(p)=19;
if ee(p)=3 then edy(p)=28;
end;
end;

if wks(p)>=0 and cwks(p)=0 and yme(p)<=0 then do;
if 0<=mos(p)<=intm then do;
yms(p)=(inty*100)+01;
yme(p)=(inty*100)+01+mos(p);
end;
do k=1 to 13;
if (intm+(k*12)-11)<=mos(p)<=(intm+(k*12)) then do;
yms(p)=((inty-k)*100)+01;
if 0<=mos(p)<=(k*12) then yme(p)=((inty-1)*100)+01+mos(p)-(k*12)+12;
if mos(p)>=((k*12)+1) then yme(p)= (inty*100) +01+mos(p)-(k*12) ;
end;
end;

sdy(p)=31;
do z=1 to 12;
if (yme(p)-(round(yms(p),100)))=mon(z) then edy(p)=ndy(z);
end;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;
end;

efl(p)=3;

end;

if yme(p)>0 and yms(p)=. then do;
if p=1 or p=(dim(csm)/2)+1 then do;
yms(p)=dliym;
sdy(p)=ddliday;
end;
if 1<p<=dim(csm)/2 or (dim(csm)/2)+1<p<=dim(csm) then do;
yms(p)=yme(p-1)+1;
do z=1 to 12;
if (yms(p)-(round(yms(p), 100)))=mon(z) then sdy(p)=ndy(z);
end;
end;

if p=1 or p=(dim(csm)/2)+1 then efl(p)=3;
else if ( 2<=p<=dim(csm)/2 or (dim(csm)/2)+2<=p<=dim(csm) ) then efl(p)=7;
end;

*** Note: if either stop month or year is ge -3 then it implies that this unemp spell has ended.
Even if R reports currently receiving that would imply another loop.;


*** (4) If stop year is known and stop month is unknown.;
if yms(p)>0 and ye(p)>0 and -3<=me(p)<=-1 then do;

** If weeks are known, then count forward from start year. If the number of months falls short
of the stop year, then use January of the end year as the stop date. If the number of months
exceeds the stop year, then end the array in the December of the stop year. Constrain stop
date by DCI. If currently receiving then use DCI as the stop date.;
if wks(p)>=0 then do;
nms(p)=yms(p)- round(yms(p),100);
if 0<=mos(p)<=(12-nms(p)) then yme(p)=yms(p)+mos(p);
do k=1 to 13;
A=k*88;
if ((k*12)+1-nms(p))<=mos(p)<=((k*12)+12-nms(p)) then yme(p)=yms(p)+A+mos(p);
end;
do z=1 to 12;
if yme(p)-round(yme(p),100)=mon(z) then edy(p)=ndy(z);
end;
if yme(p)>((ye(p)*100)+12) then do;
yme(p)=((ye(p)*100)+12);
edy(p)=31;
end;
if yme(p)<((ye(p)*100)+01) then do;
yme(p)=((ye(p)*100)+01);
edy(p)=31;
end;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;
end;

** If weeks are unknown, then set December of stop year as the stop month.;
if -3<=wks(p)<0 then do;
yme(p)=((ye(p)*100)+12);
edy(p)=31;
end;

if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;

if (efl(p) not in (2,3,7) or efl(p)=.) then efl(p)=4;
if efl(p) in (2,3,7) then efl(p)=6;

end;

*** (5) If stop year is unknown.;
if -3<=ye(p)<=-1 then do;

** If weeks are known then count forward by the number of weeks from the start date and
constrain stop date by DCI.;
if yms(p)>0 and wks(p)>=0 then do;
nms(p)=yms(p)- round(yms(p),100);
if ( 0)<=mos(p)<=(12-nms(p)+ 0) then yme(p)=yms(p)+mos(p);
do k=1 to 13;
A=k*88;
if ((k*12)+1-nms(p))<=mos(p)<=((k*12)+12-nms(p)) then yme(p)=yms(p)+A+mos(p);
end;
do z=1 to 12;
if yme(p)-round(yme(p),100)=mon(z) then edy(p)=ndy(z);
end;
if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;
end;

** If weeks are unknown then set stop date as December of start year.;
if yms(p)>0 and -3<=wks(p)<0 then do;
yme(p)=(round(yms(p),100))+12;
edy(p)=31;
end;

if yme(p)>iym then do;
yme(p)=iym;
edy(p)=intd;
end;

if (efl(p) not in (2,3,7) or efl(p)=.) then efl(p)=5;
if efl(p) in (2,3,7) then efl(p)=6;

end;

*** (6) If the start and stop years are unknown and the weeks are unknown, use DCI and DLI. ;
if -3<=ys(p)<=-1 and cwks(p)=0 and -3<=wks(p)<0 then do;
yme(p)=iym;
edy(p)=intd;
yms(p)=dliym;
sdy(p)=ddliday;

if p=1 or p=(dim(csm)/2)+1 then efl(p)=6;
else if (2<=p<=dim(csm)/2 or (dim(csm)/2)+2<=p<=dim(csm)) then efl(p)=7;

end;


*********************************************************************
** Calculate the number of days receiving if start and end year and months are the same. **
*********************************************************************;

if (yms(p)=yme(p) and yms(p)>0 and edy(p)>=0 and sdy(p)>=0) then do;
samemth=1;
** If the month has 31 days.;
if (yms(p)-round(yms(p),100)) in (1,3,5,7,8,10,12) then do;
if edy(p)>=(32-sdy(p)) then do;
sdy(p)=edy(p)-(32-sdy(p))+1;
edy(p)=0;
end;
else if edy(p)<(32-sdy(p)) then do;
sdy(p)=0;
edy(p)=0;
handedit=handedit+1;
end;
end;
** If the month has 30 days.;
if (yms(p)-round(yms(p),100)) in (4,6,9,11) then do;
if edy(p)>=(31-sdy(p)) then do;
sdy(p)=edy(p)-(31-sdy(p))+1;
edy(p)=0;
end;
else if edy(p)<(31-sdy(p)) then do;
sdy(p)=0;
edy(p)=0;
handedit=handedit+1;
end;
end;
** If the month is February.;
if (yms(p)-round(yms(p),100))=2 then do;
if edy(p)>=(29-sdy(p)) then do;
sdy(p)=edy(p)-(29-sdy(p))+1;
edy(p)=0;
end;
else if edy(p)<(29-sdy(p)) then do;
sdy(p)=0;
edy(p)=0;
handedit=handedit+1;
end;
end;
end;

******************************************************************************
** Create an estimated amount using the category reported by R. The estimated amount is the           **
** midpoint rounded down. Note that the 12th category lists $1251 the as amount. This amount was **
** chosen since the category is unbounded - the no. represents one dollar above the lower bound.     **
*******************************************************************************;

if -3<=incm(p)<=-1 and eincm(p)=1 then inc(p)=(50/7);
if -3<=incm(p)<=-1 and eincm(p)=2 then inc(p)=(125/7);
if -3<=incm(p)<=-1 and eincm(p)=3 then inc(p)=(175/7);
if -3<=incm(p)<=-1 and eincm(p)=4 then inc(p)=(225/7);
if -3<=incm(p)<=-1 and eincm(p)=5 then inc(p)=(275/7);
if -3<=incm(p)<=-1 and eincm(p)=6 then inc(p)=(351/7);

if incm(p)>-4 then afl(p)=0;

** Create the start and stop dates in CMS;
csm(p)=(round(yms(p),100)-198000)*.12+(yms(p)-round(yms(p),100));
cem(p)=(round(yme(p),100)-198000)*.12+(yme(p)-round(yme(p),100));


end; /** [E1] **/

**** Compute efls for those cases that have not already been computed.;
do p=1 to dim(csm);
if efl(p)=. and nefl(p)~=. then efl(p)=nefl(p);
end;


**** Handedits - 2;

** R reports receiving, but doesn't know whether stopped for more than a month and so we do not have
any information on stop date. We then impute the stop date to DCI and put efl=5.;
do p=1 to dim(csm);
if -3<=stpgp(p)<=-1 then do;
dataprb2=1;
handedit=handedit+1;
cem(p)=doicm;
edy(p)=intd;
efl(p)=5;
end;
end;

** Rs report receiving at DLI, currently not receiving and no periods of 2 weeks or more when they did
not receive. So we take them to be receiving till less than a month before the DCI. Set end date to be
DCI minus 1 and end day (edy) to be the day of DCI (intd). However, if intd is greater than the total
number of days in this imputed stop month then set edy to be the last day of the imputed stop month.;
do p=1 to dim(csm);
if (cur(p)=0 or cwks(p)=0) and stpgp(p)=0 then do;
dataprb3=1;
handedit=handedit+1;
cem(p)=doicm-1;
edy(p)=intd;
do z=2 to 12;
if mon(z)=iym-round(iym,100) and intd>ndy(z-1) then edy(p)=ndy(z-1);
* This is not required for z=1 i.e. Jan bcos the month bfor that is Dec which also has 31 days;
end;
efl(p)=1;
end;
end;

** Rs report currently receiving, a period of 2 weeks or more when they did not receive, have a valid
stop date but when asked if they received again, said NO so did not go through the second loop. We
create another loop from the month after the reported stop month to DCI, and put efl=7 and inc=-3. We
take the start day to be the first day of the start month and end day to be the day of the interview
(intd). If the reported stop month of the old loop is a month before DCI then the start and stop
months of the new loop will be the same i.e. the interview month. In such cases we put sdy to be intd
and edy to be zero to avoid double counting of days of the start and stop month. IF THE STOP DATE IS
DCI, THEN WE DO NOT HANDEDIT.;
do p=1 to dim(csm);
if p~=dim(csm)/2 and p~=dim(csm) then do;
if (cur(p)=1 or cwks(p)=1) and stpgp(p)=1 and ye(p)>0 and me(p)>0 and recag(p)=0 and cem(p)~=doicm
then do;
dataprb4=1;
handedit=handedit+1;
csm(p+1)=cem(p)+1;
if (yme(p)-(round(yme(p), 100)))<12 then yms(p+1)=yme(p)+1;
if (yme(p)-(round(yme(p), 100)))=12 then yms(p+1)=yme(p)-12+101;
do z=1 to 11;
if (yme(p)-(round(yme(p), 100)))=mon(z) then sdy(p+1)=ndy(z+1);
end;
if (yme(p)-(round(yme(p), 100)))=12 then sdy(p+1)=31;
cem(p+1)=doicm;
yme(p+1)=iym;
edy(p+1)=intd;
efl(p+1)=7;
afl(p+1)=0;
inc(p+1)=-3;
if cem(p)+1=doicm then do;
sdy(p+1)=intd;
edy(p+1)=0;
samemth=1;
end;
end;
end;
* Handedit these cases and then add another spell.;
if (p=dim(csm)/2 or p=dim(csm))
and (cur(p)=1 or cwks(p)=1) and stpgp(p)=1 and ye(p)>0 and me(p)>0 and recag(p)=0 and cem(p)~=doicm
then do;
dataprb4=2;
end;
end;

** If R reports a valid stop date but is not asked whether receives again then handedit as for dataprb4.;
do p=1 to dim(csm);
if p~=dim(csm)/2 and p~=dim(csm) then do;
if ((ys(p)>0 and ms(p)>0) or dli(p)=1) and (ye(p)>0 and me(p)>0) and recag(p)=-4 and cem(p)~=doicm
then do;
dataprb5=1;
handedit=handedit+1;
csm(p+1)=cem(p)+1;
if (yme(p)-(round(yme(p), 100)))<12 then yms(p+1)=yme(p)+1;
if (yme(p)-(round(yme(p), 100)))=12 then yms(p+1)=yme(p)-12+101;
do z=1 to 11;
if (yme(p)-(round(yme(p), 100)))=mon(z) then sdy(p+1)=ndy(z+1);
end;
if (yme(p)-(round(yme(p), 100)))=12 then sdy(p+1)=31;
cem(p+1)=doicm;
yme(p+1)=iym;
edy(p+1)=intd;
efl(p+1)=7;
afl(p+1)=0;
inc(p+1)=-3;
if cem(p)+1=doicm then do;
sdy(p+1)=intd;
edy(p+1)=0;
samemth=1;
end;
end;
end;
* Handedit these cases and then add another spell.;
if (p=dim(csm)/2 or p=dim(csm))
and ((ys(p)>0 and ms(p)>0) or dli(p)=1) and (ye(p)>0 and me(p)>0) and recag(p)=-4 and cem(p)~=doicm
then do;
dataprb5=2;
end;
end;


** When Rs report overlapping spells with amount receiving the same for these spells we just merge all
the consecutive spells into 1. Added on 11-15-05.;

do p=1 to dim(csm);
tcsm(p)=csm(p);
tcem(p)=cem(p);
tsdy(p)=sdy(p);
tedy(p)=edy(p);
tinc(p)=inc(p);
tefl(p)=efl(p);
tafl(p)=afl(p);
end;

do p=2 to dim(csm);
if p~=((dim(csm)/2)+1) &
(
0<tcsm(p)<tcem(p-1)
or (0<tcsm(p)=tcem(p-1) & edy(p-1)>ds(p)>0)
or (0<tcsm(p)=tcem(p-1) & edy(p-1)>0 & es(p)=1 & edy(p-1)>1)
or (0<tcsm(p)=tcem(p-1) & edy(p-1)>0 & es(p)=2 & edy(p-1)>11)
or (0<tcsm(p)=tcem(p-1) & edy(p-1)>0 & es(p)=3 & edy(p-1)>21)
)
& tefl(p)=1 & tefl(p-1)=1
& ((tinc(p)=tinc(p-1) & tinc(p)>=0)|(tinc(p)<0 & tinc(p-1)<0))
then do;
handedit=handedit+1;
dataprb6=1;

csm(p)=tcsm(p); cem(p)=tcem(p);
sdy(p)=tsdy(p); edy(p)=tedy(p);
inc(p)=tinc(p);
efl(p)=tefl(p); afl(p)=tafl(p);

if 0<tcsm(p)<tcsm(p-1) then do;
csm(p-1)=tcsm(p);
sdy(p-1)=tsdy(p);
end;
if 0<tcsm(p-1)=tcsm(p) then do;
sdy(p-1)=max(tsdy(p),tsdy(p-1));
end;
if 0<tcem(p-1)<tcem(p) then do;
cem(p-1)=tcem(p);
edy(p-1)=tedy(p);
end;
if 0<tcem(p-1)=tcem(p) then do;
edy(p-1)=max(tedy(p),tedy(p-1));
end;

csm(p)=.;
cem(p)=.;
sdy(p)=.;
edy(p)=.;
inc(p)=.;
efl(p)=.;
afl(p)=.;
end;

end;

** We corrected some of the start and stop dates after the samemth correction so there may be
new cases with the samemth problem. Here we identify those cases and handedit those.;
do p=1 to dim(csm);
if (yms(p)=yme(p) and yms(p)>0 and edy(p)>=0 and sdy(p)>=0) & samemth~=1 then samemth=2;
end;

**********************************************************************************
** Create the monthly receiving indicator (UIREC) and the monthly amount receiving (UIAMT) variables. **
**********************************************************************************;

do p=1 to dim(csm); /** [B2] **/
C=0;
do l=1 to dim(UIREC); /** [B3] **/
C=C+1;
if 0<=l<=doicm then do;
if csm(p)<=C<=cem(p) then do;
if (C=csm(p) and inc(p)>=0) then do;
if sdy(p)>0 then do;
UIAMT(l)= round((inc(p)*sdy(p)), 1);
UIREC(l)=efl(p);
end;
end;
else if (C=cem(p) and inc(p)>=0) then do;
if edy(p)>0 then do;
UIREC(l)=efl(p);
UIAMT(l)= round((inc(p)*edy(p)), 1);
end;
end;
else if csm(p)<C<cem(p) and inc(p)>=0 then do;
UIREC(l)=efl(p);
do k=1 to dim(UIRTTL);
A=(k-1)*12;
if C=169+A or C=171+A or C=173+A or C=175+A or C=176+A or C=178+A or C=180+A then do;
UIAMT(l)=round((inc(p)*31),1);
end;
if C=172+A or C=174+A or C=177+A or C=179+A then do;
UIAMT(l)=round((inc(p)*30),1);
end;
if C=170+A then do;
UIAMT(l)=round((inc(p)*28),1);
end;
end;
do k=1 to dim(UIRTTL);
A=(k-1)*48;
if C=194+A then do;
UIAMT(l)=round((inc(p)*29),1);
end;
end;
end;
** To take care of cases where a starting day is reported after the ending day both being in
the same month. The program then creates sdy=0 & edy=0. Without this condition the created
variable shows one month when R receives zero amount. However, the created variable should
show that R does not receive during that month. Added 11-14-05.;
else if inc(p)<0 & sdy(p)>0then do;
UIREC(l)=efl(p);
UIAMT(l)=inc(p);
end;
if UIAMT(l)<=10000 and (uiod=0 or uiod=.) then uiod=0;
if UIAMT(l)>10000 then uiod=1;
if UIREC(l)>0 and UIAMT(l)=. then do;
uickr=uickr+1;
end;
if (UIAMT(l)>0 or (-3<=UIAMT(l)<0)) and UIREC(l)=0 then do;
uicka=uicka+1;
end;
if UIREC(l)=-3 and UIAMT(l)~=-3 then do;
uickv=uickv+1;
end;
if UIAMT(l)=0 then dummyui=1;
end;
end;
end; /** [E3] **/
end; /** [E2] **/


**** Handedits - 3;
** If one spell ends and the next spell begins in the same months, then the program counts only the
amount received for that month from the second spell and overwrites the amount received from the
first spell. So, we add the missed amount. Find out the pubid for these Rs and handedit them.
However it may be possible that these spells overlap in which case the problem is taken care of in
dataprb6=1.;
do p=2 to dim(csm);
if ys(p)=ye(p-1) and ms(p)=me(p-1) and ys(p)>0 and ms(p)>0 then do;
prgerr1=1;
handedit=handedit+1;
end;
end;


*********************************
** Delete spells that started before DLI. **
*********************************;

**** Handedits - 4;
** R reported receiving in months prior to DLI. Since we count months receving from the month after DLI,
we fail to count the few days in the DLI month that they reported receiving. Here we add the amount
that they received during the month of DLI to the month after DLI. If the start date that they report
is earlier to the DLI day then we count only the days after the DLI day. If it is the other way round
then we count the days since the start day. We will have UIRECXXX, UIAMTXXX, inconsistent with the
start date information. Although the start date will be in one month, it will show up in UIRECXXX,
UIAMTXXX in the following month. As long as the start month is not December there will be no
inconsistencies of UIRTTLXX, UIATTLXX, UISPLSXX. However, if the start month is December then program
recipiency will show up in the variables for the following year.
When spells START BEFORE THE MONTH OF DLI then those are dataprb7=1 cases.
When spells START IN THE MONTH OF DLI but AFTER DLI then those are dataprb7=2 cases.
When spells STOP BEFORE THE MONTH OF DLI then those are dataprb7=3 cases.;

do p=1 to dim(csm);
if 0<csm(p)<cdli<cem(p) then do;
dataprb7=1;
handedit=handedit+1;
C=0;
do l=1 to dim(UIREC);
C=C+1;
if csm(p)<=C<=cdli then do;
UIREC(l)=0;
UIAMT(l)=.;
end;
if C=dlicm then do; ** Ask R about the inc(p)>=0 & UIAMT(l)>=0 condition;
if inc(p)>=0 & UIAMT(l)>=0 & dliday1>0 then UIAMT(l)=UIAMT(l)+round((dliday1*inc(p)),1);
end;
end;
end;
if csm(p)=cdli & 0<cdli<cem(p) then do;
dataprb7=2;
handedit=handedit+1;
C=0;
do l=1 to dim(UIREC);
C=C+1;
if csm(p)<=C<=cdli then do;
UIREC(l)=0;
UIAMT(l)=.;
end;
if C=dlicm then do; ** Ask R about the inc(p)>=0 & UIAMT(l)>=0 condition;
if inc(p)>=0 & UIAMT(l)>=0 & dliday1>0 & sdy(p)>0 then do;
if (dliday1+1)>sdy(p)>0 then UIAMT(l)=UIAMT(l)+round((sdy(p)*inc(p)),1);
if 0<(dliday1+1)<=sdy(p) then UIAMT(l)=UIAMT(l)+round((dliday1*inc(p)),1);
end;
end;
end;
end;
** When R reports receiving in the month of DLI and stopping in the same month (end day after the
start day) then what should we do. Where should this information be included - in the month of DLI
(cdli) or in the month after (dlicm)? If we add it to cdli then that would mean revising the event
history - not a good idea. If we add it to dlicm then it would mean reporting a new spell in this
round. This would make the information inaccurate but this method is more plausible. Added 11-16-05.
ASK R;
if 0<csm(p)=cem(p)=cdli then do;
dataprb7=3;
handedit=handedit+1;
C=0;
do l=1 to dim(UIREC);
C=C+1;
if cdli=C then do;
UIREC(l)=0;
UIAMT(l)=.;
end;
if C=dlicm then do; ** Ask R about the inc(p)>=0 condition;
UIREC(l)=1;
if inc(p)>=0 & dliday1>0 & sdy(p)>0 then do;
if (dliday1+1)>sdy(p)>0 then UIAMT(l)=round((sdy(p)*inc(p)),1);
if 0<(dliday1+1)<=sdy(p) then UIAMT(l)=round((dliday1*inc(p)),1);
end;
if -4<inc(p)<0 then UIAMT(l)=inc(p);
end;
end;
end;
if 0<csm(p)<=cem(p)<cdli then do;
dataprb7=4;
handedit=handedit+1;
C=0;
do l=1 to dim(UIREC);
C=C+1;
if csm(p)<=C<=cdli then do;
UIREC(l)=0;
UIAMT(l)=.;
end;
end;
end;
end;


*********************************************************************************
** Create the following variables - months receiving in each year (umxx), the amount receiving each         **
** year (uamtxx), the number of UNEMP spells started each year (nuxx) and the total number of months **
** received ever (ttlu) - as reported in this round.                                                                                    **
*********************************************************************************;

if UIEV>-4 then do;

** Initialize the intermediate created variables (created based on reports in this round).;
ttlu=0;
do j=1 to dim(UIRTTL);
um(j)=0;
uamt(j)=0;
ua(j)=0;
un(j)=0;
nu(j)=0;
end;

** Compute nuxx.;
do p=1 to dim(csm);
if ((csm(p)>dlicm) and (0<csm(p)<=cem(p)))
or ((csm(p)=dlicm) and (dli(p)~=1) and (0<csm(p)<=cem(p)))
then do;
do j=1 to dim(UIRTTL);
if ((12*j)-11)<=csm(p)<=(12*j) then nu(j)=nu(j)+1;
end;
end;
if ((0<csm(p)<dlicm) and (cem(p)>=dlicm) and (dli(p)~=1))
or (dataprb7=3 & csm(p)=cem(p)=cdli) then do;
do j=1 to dim(UIRTTL);
if ((12*j)-11)<=dlicm<=(12*j) then nu(j)=nu(j)+1;
end;
end;
end;

** Compute uiodttl.;
do l=1 to dim(UIREC);
if UIREC(l)>0 and UIAMT(l)>10000 and uiod=1 then do;
uiodttl=uiodttl+1;
end;
end;

** Divide the problematic amount by the total number of months receiving these problematic amounts.;
do l=1 to dim(UIREC);
if UIAMT(l)>10000 and uiodttl>0 and UIREC(l)>0 then do;
UIAMT(l)=round(UIAMT(l)/uiodttl, 1);
end;
end;

** Compute umxx and uamtxx;
do j=1 to dim(UIRTTL);
do l=((j*12)-11) to (j*12);
if um(j)>=0 and UIREC(l)>0 then do;
um(j)=um(j)+1;
end;
if UIREC(l)>1 then um(j)=-3;
if -3<=UIAMT(l)<=-1 then do;
un(j)=un(j)+1;
uamt(j)=UIAMT(l);
end;
if UIAMT(l)>=0 then do;
ua(j)=ua(j)+1;
if ua(j)=1 and un(j)=0 then uamt(j)=UIAMT(l);
if ua(j)>1 and un(j)=0 then uamt(j)=uamt(j)+UIAMT(l);
if um(j)=-3 then uamt(j)=-3;
end;
end;
end;

** Compute ttlu.;
do l=1 to dim(UIREC);
if ttlu>=0 and UIREC(l)=1 then do;
ttlu=ttlu+1;
end;
if UIREC(l)>1 or UIREC(l) in (-1,-2,-3) then ttlu=-3;
end;

end;


*****************************************************************
** Create the final variables by combining information from this and earlier rounds. **
*****************************************************************;

** Calculate the total number of months ever received (UIEV).;
if ttlu>=0 and UIEV>=0 then do;
UIEV=ttlu+UIEV;
end;
if ttlu in (-1,-2,-3) or UIEV in (-1,-2,-3) then UIEV=-3;

** Calculate the total number of UNEMP spells received in each year (UISPLSXX).;
do j=1 to dim(UIRTTL);
if nu(j)>=0 and UISPLS(j)>=0 then UISPLS(j)=nu(j)+UISPLS(j);
if UISPLS(j) in (-1,-2,-3) or nu(j) in (-1,-2,-3) then UISPLS(j)=-3;
if nu(j)=0 and ouispls(j)=-4 then UISPLS(j)=-4;
end;

** Calculate the total number of months received in each year (UIRTTLXX) and the total amount
receiving in each year (UIATTLXX).;
do j=1 to dim(UIRTTL);
if um(j)>=0 and UIRTTL(j)>=0 then do;
UIRTTL(j)=um(j)+UIRTTL(j);
end;
if um(j)<0 or UIRTTL(j)<0 then do;
UIRTTL(j)=-3;
end;
if uamt(j)>=0 and UIATTL(j)>=0 then do;
UIATTL(j)=uamt(j)+UIATTL(j);
end;
if uamt(j)<0 or UIATTL(j)<0 or UIRTTL(j)<0 then do;
UIATTL(j)=-3;
end;
if uamt(j)=0 and ouiattl(j)=-4 and UIRTTL(j)=0 then do;
UIATTL(j)=-4;
end;
end;


**** Handedits - 6;
** R received UNEMP COMP at DLI. In this round R reports that R stopped receiving in that same month, a
few days after DLI. By convention we count UNEMP spells in months and so if they continued to receive
in the next round we start the spell in the next round in the month after DLI. In this case it results
in their computed start dates being after their actual stop dates. We thus do not count these spells.
By doing so we do not count the few days that they did receive after DLI. Here we add back those
amounts to the corresponding yearly amount (UIATTL). We do not handedit any other variable.
If the end day is before the day of last interview we flag those as being data problems (dataprb8);
do p=1 to dim(csm);
if dli(p)=1 and ye(p)>0 and me(p)>0 and cem(p)=cdli then do;

if 0<dli_d<de(p) or (0<dli_d<9 and ee(p)=1) or (0<dli_d<19 and ee(p)=2) or (0<dli_d<28 and ee(p)=3)
then do; ** Ask R about the inc(p)>=0 & UIATTL(j)>=0 condition;
prgerr2=1;
do j=1 to dim(UIRTTL);
if ((j*12)-11)<=cdli<=(j*12) then do;
if inc(p)>=0 & UIATTL(j)>=0 then do;
if 0<dli_d<de(p) then UIATTL(j)=UIATTL(j)+(inc(p)*(de(p)-dli_d));
if (0<dli_d< 9 and ee(p)=1) then UIATTL(j)=UIATTL(j)+(inc(p)*( 9-dli_d));
if (0<dli_d<19 and ee(p)=2) then UIATTL(j)=UIATTL(j)+(inc(p)*(19-dli_d));
if (0<dli_d<28 and ee(p)=3) then UIATTL(j)=UIATTL(j)+(inc(p)*(28-dli_d));
end;
end;
end;

end;

if dli_d>de(p)>0 or (dli_d>9 and ee(p)=1) or (dli_d>19 and ee(p)=2) or (dli_d>28 and ee(p)=3)
then dataprb8=1;

end;
end;


**********************************************/

** Change all invalid skips to -3.;

array vars UIRTTL80-UIRTTL99 UIRTTL00 UIRTTL01-UIRTTL05
UIATTL80-UIATTL99 UIATTL00 UIATTL01-UIATTL05
UISPLS80-UISPLS99 UISPLS00 UISPLS01-UISPLS05
UIEV;

do over vars;
if vars=-2 then vars=-3;
if vars=-1 then vars=-3;
end;



ENDSAS;
 

Return to top


Household Net Worth: Over 20 Assets Section

Variables Created:

Variables Used

      These variables are listed in a separate file (due to the length of the list).

Several asset variables that better capture a respondent’s financial position at the date of the survey and at a certain age were first created in round 8 for respondents who answered the asset questions asked in the first survey after their 20th birthday.  Using data from past rounds, the respondent’s financial position at age 20 includes the following:

      -total net worth (CV_HH_NET_WORTH_20),
      -the value of owned housing (CV_HOUSE_VALUE_20),
      -the value of housing debt (CV_HOUSE_DEBT_20),
      -the type of housing owned (CV_HOUSE_TYPE_20),
      -the value of financial assets (CV_ASSETS_FINANCE_20),
      -the value of non-financial assets (excluding housing) (CV__ASSETS_NONFINANCE_20),
      -the amount of debt (excluding housing) (CV_ASSETS_DEBT_20), and
      -the round in which assets data were collected (CV_ASSETS_20)

These variables will be updated each round for the appropriate age.  In round 8, only those answering the age 20 module go through the assets section.  In the case of Round 9, these variables would be updated for any who received the age 20 module and a new set will begin for those who receive the new assets module at age 25. 

Researchers should note that, like many income and asset variables in the data set, this variable is topcoded to protect respondent privacy.  More information about topcoding is available in the NLSY97 User's Guide.

Return to top


Round 3

******************* Start of the Youth Asset Section (hhworthY) ********************;
**First create the following components of the hhworthY such as real estate, loans,                 **;
** cars etc.Each subsection computes one item of the total asset of Youth Respondent            **;
** and his/her spouse or partner. Flag variables are created to indicate whether                       **;
** R/family received that asset item (FLAG_item in (1,2,-3)) and if so was the amount            **;
** computed directly from the amount reported by R (FLAG_item=1) or it was computed      **;
** from estimates given by R (FLAG_item=2) or it could not be computed (FLAG_item=-3). **;
**************************************************************************;

housing_type=-4;
house_value=-4;


****************************************************;
** If the respondent owns some land, its present value - pvranch. **;
****************************************************;

pvranch=-4;
*** If R alone or R and R's partner/spouse jointly own all of it. ***;
if yas1400=1 & (yas1610=1 or yas1610=2) then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas1860=1 & yas1862>=0 then pvranch=yas1862; /*how about lt 0?*/
else if yas1860=2 & yas1864L>=0 & yas1864U>=0 then do;
if yas1864U>=yas1864L then pvranch=(yas1864L+yas1864U)/2;
else pvranch=-3;
end;
if yas1860 not in (1,2) or yas1862 in (-1,-2) then do;
if 1<=yas1866<=7 then FLAG_pvranch=2;
if yas1866=1 then pvranch=12500;
else if yas1866=2 then pvranch=37500;
else if yas1866=3 then pvranch=75000;
else if yas1866=4 then pvranch=175000;
else if yas1866=5 then pvranch=375000;
else if yas1866=6 then pvranch=750000;
else if yas1866=7 then pvranch=1000001;
end;
end;


*** If R alone or R and R's partner/spouse jointly own part of it (100%). ***;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2140=1 & yas2142>=0 then pvranch=yas2142;
else if yas2140=2 & yas2144L>=0 & yas2144U>=0 then do;
if yas2144U>=yas2144L then pvranch=(yas2144L+yas2144U)/2;
else pvranch=-3;
end;
if yas2140 not in (1,2) or yas2142 in (-1,-2) then do;
if 1<=yas2146<=7 then FLAG_pvranch=2;
if yas2146=1 then pvranch=12500;
else if yas2146=2 then pvranch=37500;
else if yas2146=3 then pvranch=75000;
else if yas2146=4 then pvranch=175000;
else if yas2146=5 then pvranch=375000;
else if yas2146=6 then pvranch=750000;
else if yas2146=7 then pvranch=1000001;
end;
end;


** If R alone or R and R's partner/spouse jointly own part of it (< 100%) **;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120~=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2170=1 & yas2172>=0 then pvranch=yas2172;
else if yas2170=2 & yas2174L>=0 & yas2174U>=0 then do;
if yas2174U>=yas2174L then pvranch=(yas2174L+yas2174U)/2;
else pvranch=-3;
end;
if yas2170 not in (1,2) or yas2172 in (-1,-2) then do;
if 1<=yas2176<=7 then FLAG_pvranch=2;
if yas2176=1 then pvranch=12500;
else if yas2176=2 then pvranch=37500;
else if yas2176=3 then pvranch=75000;
else if yas2176=4 then pvranch=175000;
else if yas2176=5 then pvranch=375000;
else if yas2176=6 then pvranch=750000;
else if yas2176=7 then pvranch=1000001;
end;
end;

if yas1400=-1 or yas1610=-1
or yas1864L=-1 or yas1864U=-1 or yas1866=-1
or yas2144L=-1 or yas2144U=-1 or yas2146=-1
or yas2174L=-1 or yas2174U=-1 or yas2176=-1 then pvranch=-1;

if yas1400=-2 or yas1610=-2
or yas1864L=-2 or yas1864U=-2 or yas1866=-2
or yas2144L=-2 or yas2144U=-2 or yas2146=-2
or yas2174L=-2 or yas2174U=-2 or yas2176=-2 then pvranch=-2;

if yas1400=-3 or yas1610=-3
or yas1864L=-3 or yas1864U=-3 or yas1866=-3
or yas2144L=-3 or yas2144U=-3 or yas2146=-3
or yas2174L=-3 or yas2174U=-3 or yas2176=-3
or yas1862=-3 or yas2142=-3 or yas2172=-3 then pvranch=-3;

if flag_pvranch=1 then do;
housing_type=2;
house_value=pvranch;
end;

if yas1610=6 then do;
housing_type=6;
house_value=-4;
end;

********* this is the end of land part. ***************;


*******************************************************;
** If R alone or R and R's partner/spouse jointly own a mobile home **;
** and its site, its present value - pvmbst.                                          **;
*******************************************************;

pvmbst=-4;
if yas2520 in (1,2) then do;
FLAG_pvmbst=1;
flagck_mbst=1;
if yas2550=1 & yas2552>=0 then pvmbst=yas2552;
else if yas2550=2 & yas2554L>=0 & yas2554U>=0 then do;
if yas2554U>=yas2554L then pvmbst=(yas2554L+yas2554U)/2;
else pvmbst=-3;
end;
if yas2550 not in (1,2) or yas2552 in (-1,-2) then do;
if 1<=yas2556<=7 then FLAG_pvmbst=2;
if yas2556=1 then pvmbst=500;
else if yas2556=2 then pvmbst=1750;
else if yas2556=3 then pvmbst=3750;
else if yas2556=4 then pvmbst=7500;
else if yas2556=5 then pvmbst=17500;
else if yas2556=6 then pvmbst=37500;
else if yas2556=7 then pvmbst=50001;
end;
end;
if yas2520=-1 or yas2554L=-1 or yas2554U=-1 or yas2556=-1 then pvmbst=-1;
if yas2520=-2 or yas2554L=-2 or yas2554U=-2 or yas2556=-2 then pvmbst=-2;
if yas2520=-3 or yas2554L=-3 or yas2554U=-3 or yas2556=-3 or yas2552=-3 then pvmbst=-3;

if flag_pvmbst=1 then do;
housing_type=4;
house_value=pvmbst;
end;

***** this is the end of mobile home & site. *****;


*******************************************************;
** If R alone or R and R's partner/spouse jointly own a mobile home, **;
** its present value - pvmb.                                                                **;
*******************************************************;

pvmb=-4;
if yas2520 in (3,4) then do;
FLAG_pvmb=1;
flagck_mb=1;
if yas2760=1 & yas2762>=0 then pvmb=yas2762;
else if yas2760=2 & yas2764L>=0 & yas2764U>=0 then do;
if yas2764U>=yas2764L then pvmb=(yas2764L+yas2764U)/2;
else pvmb=-3;
end;
if yas2760 not in (1,2) or yas2762 in (-1,-2) then do;
if 1<=yas2766<=7 then FLAG_pvmb=2;
if yas2766=1 then pvmb=12500;
else if yas2766=2 then pvmb=37500;
else if yas2766=3 then pvmb=75000;
else if yas2766=4 then pvmb=175000;
else if yas2766=5 then pvmb=375000;
else if yas2766=6 then pvmb=750000;
else if yas2766=7 then pvmb=1000001;
end;
end;
if yas2520=-1 or yas2764L=-1 or yas2764U=-1 or yas2766=-1 then pvmb=-1;
if yas2520=-2 or yas2764L=-2 or yas2764U=-2 or yas2766=-2 then pvmb=-2;
if yas2520=-3 or yas2764L=-3 or yas2764U=-3 or yas2766=-3 or yas2762=-3 then pvmb=-3;

if flag_pvmb=1 then do;
housing_type=3;
house_value=pvmb;
end;

***** this is the end of mobile home. *****;


**********************************************************;
** If R alone or R and R's partner/spouse jointly own a mobile home site, **;
** its present value - pvst.                                                                        **;
**********************************************************;

pvst=-4;
if yas2520 in (5,6) then do;
FLAG_pvst=1;
flagck_st=1;
if yas3010=1 & yas3012>=0 then pvst=yas3012;
else if yas3010=2 & yas3014L>=0 & yas3014U>=0 then do;
if yas3014U>=yas3014L then pvst=(yas3014L+yas3014U)/2;
else pvst=-3;
end;
if yas3010 not in (1,2) or yas3012 in (-1,-2) then do;
if 1<=yas3016<=7 then FLAG_pvst=2;
if yas3016=1 then pvst=12500;
else if yas3016=2 then pvst=57500;
else if yas3016=3 then pvst=75000;
else if yas3016=4 then pvst=175000;
else if yas3016=5 then pvst=575000;
else if yas3016=6 then pvst=750000;
else if yas3016=7 then pvst=1000001;
end;
end;
if yas2520=-1 or yas3014L=-1 or yas3014U=-1 or yas3016=-1 then pvst=-1;
if yas2520=-2 or yas3014L=-2 or yas3014U=-2 or yas3016=-2 then pvst=-2;
if yas2520=-3 or yas3014L=-3 or yas3014U=-3 or yas3016=-3 or yas3012=-3 then pvst=-3;

if flag_pvst=1 then do;
housing_type=5;
house_value=pvst;
end;

if yas2520=8 then do;
housing_type=6;
house_value=-4;
end;
***** this is the end of mobile home site. *****;

*****************************************************;
** THIS IS THE END OF MOBILE HOME & ITS SITE PART. **;
*****************************************************;


******************************************************;
** If R alone or R and R's partner/spouse jointly own an apartment, **;
** its present value - pvapt.                                                             **;
******************************************************;

pvapt=-4;
if yas3310 in (1,2) then do;
FLAG_pvapt=1;
flagck_apt=1;
if yas3380=1 & yas3382>=0 then pvapt=yas3382;
else if yas3380=2 & yas3384L>=0 & yas3384U>=0 then do;
if yas3384U>=yas3384L then pvapt=(yas3384L+yas3384U)/2;
else pvapt=-3;
end;
if yas3380 not in (1,2) or yas3382 in (-1,-2) then do;
if 1<=yas3386<=7 then FLAG_pvapt=2;
if yas3386=1 then pvapt=500;
else if yas3386=2 then pvapt=1750;
else if yas3386=3 then pvapt=3750;
else if yas3386=4 then pvapt=7500;
else if yas3386=5 then pvapt=17500;
else if yas3386=6 then pvapt=37500;
else if yas3386=7 then pvapt=50001;
end;
end;
if yas3310=-1 or yas3384L=-1 or yas3384U=-1 or yas3386=-1 then pvapt=-1;
if yas3310=-2 or yas3384L=-2 or yas3384U=-2 or yas3386=-2 then pvapt=-2;
if yas3310=-3 or yas3384L=-3 or yas3384U=-3 or yas3386=-3 or yas3382=-3 then pvapt=-3;

if yas3310 in (1,2) and yas3340=0 then housing_type=1;
else if yas3310 in (1,2) and yas3340=1 and yas3360=1 then housing_type=8;
else if yas3310 in (1,2) and yas3340=1 and yas3360=2 then housing_type=7;

if flag_pvapt=1 then house_value=pvapt;

if yas3310=4 then do;
housing_type=6;
house_value=-4;
end;


********** this is the end of apartment part. *********************;


****************************************************;
** If R alone or R and R's partner/spouse jointly own a business,  **;
** partnership or professional practice, its present value - pvbuss. **;
****************************************************;

pvbuss=-4;
if yas4010 in (1,2) then do;
FLAG_pvbuss=1;
if yas4030=1 & yas4032 not in (-1,-2,-3,-4) then pvbuss=yas4032;
else if yas4030=2 then pvbuss=(yas4034L+yas4034U)/2;
if yas4030 not in (1,2) or yas4032 in (-1,-2) then do;
if 1<=yas4036<=7 then FLAG_pvbuss=2;
if yas4036=1 then pvbuss=12500;
else if yas4036=2 then pvbuss=37500;
else if yas4036=3 then pvbuss=75000;
else if yas4036=4 then pvbuss=175000;
else if yas4036=5 then pvbuss=375000;
else if yas4036=6 then pvbuss=750000;
else if yas4036=7 then pvbuss=1000001;
end;
end;
if yas4010=-1 or yas4034L=-1 or yas4034U=-1 or yas4036=-1 then pvbuss=-1;
if yas4010=-2 or yas4034L=-2 or yas4034U=-2 or yas4036=-2 then pvbuss=-2;
if yas4010=-3 or yas4034L=-3 or yas4034U=-3 or yas4036=-3 or yas4032=-3 then pvbuss=-3;

********* this is the end of business part. *****************;


**************************************************;
** If R alone or R and R's partner/spouse jointly own a second **;
** real estate, its present value - othreal.                                   **;
**************************************************;

othreal=-4;
if yas4140 in (1,2) then do;
FLAG_othreal=1;
if yas4160=1 & yas4162>=0 then othreal=yas4162;
else if yas4160=2 & yas4164U>=0 & yas4164L>=0 then do;
if yas4164U>=yas4164L then othreal=(yas4164L+yas4164U)/2;
else othreal=-3;
end;
if yas4160 not in (1,2) or yas4162 in (-1,-2) then do;
if 1<=yas4166<=7 then FLAG_othreal=2;
if yas4166=1 then othreal=12500;
else if yas4166=2 then othreal=37500;
else if yas4166=3 then othreal=75000;
else if yas4166=4 then othreal=175000;
else if yas4166=5 then othreal=375000;
else if yas4166=6 then othreal=750000;
else if yas4166=7 then othreal=1000001;
end;
end;
if yas4140=-1 or yas4164L=-1 or yas4164U=-1 or yas4166=-1 then othreal=-1;
if yas4140=-2 or yas4164L=-2 or yas4164U=-2 or yas4166=-2 then othreal=-2;
if yas4140=-3 or yas4164L=-3 or yas4164U=-3 or yas4166=-3 or yas4162=-3 then othreal=-3;

**************** this is the end of other real estate. ********************;


*********************************************************;
** If R or R's partner/spouse have retirement plans or pensions - retdsav **;
*********************************************************;

retdsav=-4;
if yas4270 in (1,2,3) then do;
FLAG_retdsav=1;
if yas4290=1 & yas4292>=0 then retdsav=yas4292;
else if yas4290=2 & yas4294U>=0 & yas4294L>=0 then retdsav=(yas4294L+yas4294U)/2;
if yas4290 not in (1,2) or yas4292 in (-1,-2) then do;
if 1<=yas4296<=7 then FLAG_retdsav=2;
if yas4296=1 then retdsav=2500;
else if yas4296=2 then retdsav=7500;
else if yas4296=3 then retdsav=17500;
else if yas4296=4 then retdsav=37500;
else if yas4296=5 then retdsav=75000;
else if yas4296=6 then retdsav=175000;
else if yas4296=7 then retdsav=250001;
end;
end;
if yas4270=-1 or yas4294L=-1 or yas4294U=-1 or yas4296=-1 then retdsav=-1;
if yas4270=-2 or yas4294L=-2 or yas4294U=-2 or yas4296=-2 then retdsav=-2;
if yas4270=-3 or yas4294L=-3 or yas4294U=-3 or yas4296=-3 or yas4292=-3 then retdsav=-3;

******** this is the end of retirement plans. ****************;


**************************************************;
** If R or R's partner/spouse have banksav in saving accounts, **;
** money market, funds,trusts, - banksav.                                **;
**************************************************;

banksav=-4;
if yas4400 in (1,2,3) then do;
FLAG_banksav=1;
if yas4420=1 & yas4422>=0 then banksav=yas4422;
else if yas4420=2 & yas4424U>=0 & yas4424L>=0 then do;
if yas4424U>=yas4424L then banksav=(yas4424L+yas4424U)/2;
else banksav=-3;
end;
if yas4420 not in (1,2) or yas4422 in (-1,-2) then do;
if 1<=yas4426<=7 then FLAG_banksav=2;
if yas4426=1 then banksav=500;
else if yas4426=2 then banksav=1750;
else if yas4426=3 then banksav=3750;
else if yas4426=4 then banksav=7500;
else if yas4426=5 then banksav=17500;
else if yas4426=6 then banksav=37500;
else if yas4426=7 then banksav=50001;
end;
end;
if yas4400=-1 or yas4424L=-1 or yas4424U=-2 or yas4426=-1 then banksav=-1;
if yas4400=-2 or yas4424L=-2 or yas4424U=-2 or yas4426=-2 then banksav=-2;
if yas4400=-3 or yas4424L=-3 or yas4424U=-3 or yas4426=-3 or yas4422=-3 then banksav=-3;

************* this is the end of bank savings. ****************;


***********************************************************;
** If R or R's partner/spouse have other banksav in bonds or cds - bonds. **;
***********************************************************;

bonds=-4;
if yas4530 in (1,2,3) then do;
FLAG_bonds=1;
if yas4550=1 & yas4552>=0 then bonds=yas4552;
else if yas4550=2 & yas4554U>=0 & yas4554L>=0 then bonds=(yas4554L+yas4554U)/2;
if yas4550 not in (1,2) or yas4552 in (-1,-2) then do;
if 1<=yas4556<=7 then FLAG_bonds=2;
if yas4556=1 then bonds=500;
else if yas4556=2 then bonds=1750;
else if yas4556=3 then bonds=3750;
else if yas4556=4 then bonds=7500;
else if yas4556=5 then bonds=17500;
else if yas4556=6 then bonds=37500;
else if yas4556=7 then bonds=50001;
end;
end;
if yas4530=-1 or yas4554L=-1 or yas4554U=-1 or yas4556=-1 then bonds=-1;
if yas4530=-2 or yas4554L=-2 or yas4554U=-2 or yas4556=-2 then bonds=-2;
if yas4530=-3 or yas4554L=-3 or yas4554U=-3 or yas4556=-3 or yas4552=-3 then bonds=-3;

***************** this is the end of bonds. **********************;


*** If the respondent or his/her partner/spouse have stocks, mutual funds - stocks;

stocks=-4;
if yas4660 in (1,2,3) then do;
FLAG_stocks=1;
if yas4680=1 & yas4682>=0 then stocks=yas4682;
else if yas4680=2 & yas4684L>=0 & yas4684U>=0 then do;
if yas4684U>=yas4684L then stocks=(yas4684L+yas4684U)/2;
else stocks=-3;
end;
if yas4680 not in (1,2) or yas4682 in (-1,-2) then do;
if 1<=yas4686<=7 then FLAG_stocks=2;
if yas4686=1 then stocks=500;
else if yas4686=2 then stocks=1750;
else if yas4686=3 then stocks=3750;
else if yas4686=4 then stocks=7500;
else if yas4686=5 then stocks=17500;
else if yas4686=6 then stocks=37500;
else if yas4686=7 then stocks=50001;
end;
end;
if yas4660=-1 or yas4684L=-1 or yas4684U=-1 or yas4686=-1 then stocks=-1;
if yas4660=-2 or yas4684L=-2 or yas4684U=-2 or yas4686=-2 then stocks=-2;
if yas4660=-3 or yas4684L=-3 or yas4684U=-3 or yas4686=-3 or yas4682=-3 then stocks=-3;

****************** this is the end of stocks. ***********************;


******************************************************;
** If the respondent alone or respondent and his/her partner/spouse **;
** jointly own vehicles, their present value - pvcars.                         **;
******************************************************;

pvcars=-4;
if yas4790 in (1,2,3) then do;
FLAG_pvcars=1;
if yas4810=1 & yas4812>=0 then pvcars=yas4812;
else if yas4810=2 & yas4814L>=0 & yas4814U>=0 then do;
if yas4814U>=yas4814L then pvcars=(yas4814L+yas4814U)/2;
else pvcars=-3;
end;
if yas4810 not in (1,2) or yas4812 in (-1,-2) then do;
if 1<=yas4816<=7 then FLAG_pvcars=2;
if yas4816=1 then pvcars=2500;
else if yas4816=2 then pvcars=7500;
else if yas4816=3 then pvcars=17500;
else if yas4816=4 then pvcars=37500;
else if yas4816=5 then pvcars=75000;
else if yas4816=6 then pvcars=175000;
else if yas4816=7 then pvcars=250001;
end;
end;
if yas4790=-1 or yas4814L=-1 or yas4814U=-1 or yas4816=-1 then pvcars=-1;
if yas4790=-2 or yas4814L=-2 or yas4814U=-2 or yas4816=-2 then pvcars=-2;
if yas4790=-3 or yas4814L=-3 or yas4814U=-3 or yas4816=-3 or yas4812=-3 then pvcars=-3;

***************** this is the end of vehicles part. **********************;


**************************************************;
** If R alone or R and R's partner/spouse jointly own furniture, **;
** its present value - pvfurn.                                                     **;
**************************************************;

pvfurn=-4;
if yas4870>-4 then FLAG_pvfurn=1;
if yas4870=1 then pvfurn=2500;
else if yas4870=2 then pvfurn=7500;
else if yas4870=3 then pvfurn=17500;
else if yas4870=4 then pvfurn=37500;
else if yas4870=5 then pvfurn=75000;
else if yas4870=6 then pvfurn=175000;
else if yas4870=7 then pvfurn=250001;
else if yas4870=-1 then pvfurn=-1;
else if yas4870=-2 then pvfurn=-2;
else if yas4870=-3 then pvfurn=-3;

************** this is the end of furniture part. *****************;


*******************************************************;
** If R alone or R and R's partner/spouse jointly own other assets not **;
** mentioned before - othsav.                                                            **;
*******************************************************;

othsav=-4;
if yas4880 in (1,2,3) then do;
FLAG_othsav=1;
if yas4900=1 & yas4902>=0 then othsav=yas4902;
else if yas4900=2 & yas4904L>=0 & yas4904U>=0 then othsav=(yas4904L+yas4904U)/2;
if yas4900 not in (1,2) or yas4902 in (-1,-2) then do;
if 1<=yas4906<=7 then FLAG_othsav=2;
if yas4906=1 then othsav=2500;
else if yas4906=2 then othsav=7500;
else if yas4906=3 then othsav=17500;
else if yas4906=4 then othsav=37500;
else if yas4906=5 then othsav=75000;
else if yas4906=6 then othsav=175000;
else if yas4906=7 then othsav=250001;
end;
end;
if yas4880=-1 or yas4904L=-1 or yas4904U=-1 or yas4906=-1 then othsav=-1;
if yas4880=-2 or yas4904L=-2 or yas4904U=-2 or yas4906=-2 then othsav=-2;
if yas4880=-3 or yas4904L=-3 or yas4904U=-3 or yas4906=-3 or yas4902=-3 then othsav=-3;

************** this is the end of other savings. **********************;


***********************************;
** THIS IS THE END OF ASSETS.        **;
** THE FOLLOWING IS LIABILITIES. **;
***********************************;


*****************************************************;
** If there is mortgage or land contract on the aforementioned land **;
** or property - mortgag.                                                              **;
*****************************************************;

mortgag=-4;
if yas3740 in (1,2) then do;
FLAG_mortgag=1;
if yas3750=1 & yas3752>=0 then mortgag=yas3752;
else if yas3750=2 & yas3754L>=0 & yas3754U>=0 then mortgag=(yas3754L+yas3754U)/2;
if yas3750 not in (1,2) or yas3752 in (-1,-2) then do;
if 1<=yas3756<=7 then FLAG_mortgag=2;
if yas3756=1 then mortgag=500;
else if yas3756=2 then mortgag=1750;
else if yas3756=3 then mortgag=3750;
else if yas3756=4 then mortgag=7500;
else if yas3756=5 then mortgag=17500;
else if yas3756=6 then mortgag=37500;
else if yas3756=7 then mortgag=50001;
end;
end;
if yas3740=-1 or yas3754L=-1 or yas3754U=-1 or yas3756=-1 then mortgag=-1;
if yas3740=-2 or yas3754L=-2 or yas3754U=-2 or yas3756=-2 then mortgag=-2;
if yas3740=-3 or yas3754L=-3 or yas3754U=-3 or yas3756=-3 or yas3752=-3 then mortgag=-3;

***************** this is the end of mortgage part. *******************;


****************************************************;
** If R or R's partner/spouse has unpaid loans from Round 7       **;
** (yas3840=1 & yas3850=1) or still owes loans taken SDLI on **;
** house (yas3860=1) then total amount owed - resdebt.             **;
****************************************************;

resdebt=-4;
if (yas3840=1 & yas3850=1) or yas3860=1 then do;
FLAG_resdebt=1;
if yas3880=1 & yas3882>=0 then resdebt=yas3882;
else if yas3880=2 & yas3884U>=0 & yas3884L>=0 then resdebt=(yas3884L+yas3884U)/2;
if yas3880 not in (1,2) or yas3882 in (-1,-2) then do;
if 1<=yas3886<=7 then FLAG_resdebt=2;
if yas3886=1 then resdebt=500;
else if yas3886=2 then resdebt=1750;
else if yas3886=3 then resdebt=3750;
else if yas3886=4 then resdebt=7500;
else if yas3886=5 then resdebt=17500;
else if yas3886=6 then resdebt=37500;
else if yas3886=7 then resdebt=50001;
end;
end;
if yas3850=-1 or yas3860=-1 or yas3884L=-1 or yas3884U=-1 or yas3886=-1
then resdebt=-1;
if yas3850=-2 or yas3860=-2 or yas3884L=-2 or yas3884U=-2 or yas3886=-2
then resdebt=-2;
if yas3850=-3 or yas3860=-3 or yas3884L=-3 or yas3884U=-3 or yas3886=-3 or yas3882=-3
then resdebt=-3;

***** this is the end of resdebt. *****;


***********************************************;
** If the respondent or his/her partner/spouse have second **;
** mortgages - othmort.                                                     **;
***********************************************;

othmort=-4;
if yas3910=1 then do;
FLAG_othmort=1;
if yas3920=1 & yas3922>=0 then othmort=yas3922;
else if yas3920=2 & yas3924U>=0 & yas3924L>=0 then othmort=(yas3924L+yas3924U)/2;
if yas3920 not in (1,2) or yas3922 in (-1,-2) then do;
if 1<=yas3926<=7 then FLAG_othmort=2;
if yas3926=1 then othmort=500;
else if yas3926=2 then othmort=1750;
else if yas3926=3 then othmort=3750;
else if yas3926=4 then othmort=7500;
else if yas3926=5 then othmort=17500;
else if yas3926=6 then othmort=37500;
else if yas3926=7 then othmort=50001;
end;
end;
if yas3910=-1 or yas3924L=-1 or yas3924U=-1 or yas3926=-1 then othmort=-1;
if yas3910=-2 or yas3924L=-2 or yas3924U=-2 or yas3926=-2 then othmort=-2;
if yas3910=-3 or yas3924L=-3 or yas3924U=-3 or yas3926=-3 or yas3922=-3 then othmort=-3;

***** this is the end of other mortgage. *****;


**********************************************************;
** If R or R's partner/spouse still owe money on these vehicles - cardebt. **;
**********************************************************;

cardebt=-4;
if yas4840>-4 then FLAG_cardebt=1;
if yas4840=1 & yas4842>=0 then cardebt=yas4842;
else if yas4840=2 & yas4844L>=0 & yas4844U>=0 then cardebt=(yas4844L+yas4844U)/2;
if yas4840 not in (1,2) or yas4842 in (-1,-2) then do;
if 1<=yas4846<=7 then FLAG_cardebt=2;
if yas4846=1 then cardebt=2500;
else if yas4846=2 then cardebt=7500;
else if yas4846=3 then cardebt=17500;
else if yas4846=4 then cardebt=37500;
else if yas4846=5 then cardebt=75000;
else if yas4846=6 then cardebt=175000;
else if yas4846=7 then cardebt=250001;
end;
if yas4790=-1 or yas4844L=-1 or yas4844U=-1 or yas4846=-1 then cardebt=-1;
if yas4790=-2 or yas4844L=-2 or yas4844U=-2 or yas4846=-2 then cardebt=-2;
if yas4790=-3 or yas4844L=-3 or yas4844U=-3 or yas4846=-3 or yas4842=-3 then cardebt=-3;

**************** this is the end of car debt. **********************;

/*
*************************famedudebt**********************************;

famedudebt=-4;
if yas5011=1 then do;
flag_famedudebt=1;
if yas5011A=1 & yas5012>=0 then famedudebt=yas5012;
else if yas5011A=2 then do;
if yas5013L>=0 & yas5013U>=yas5013L then famedudebt=(yas5013L+yas5013U)/2;
else famedudebt=-3;
end;
if yas5011A not in (1,2) or yas5012 in (-1,-2) then do;
if 1<=yas5014<=7 then flag_famedudebt=2;
if yas5014=1 then famedudebt=500;
else if yas5014=2 then famedudebt=1750;
else if yas5014=3 then famedudebt=3750;
else if yas5014=4 then famedudebt=7500;
else if yas5014=5 then famedudebt=17500;
else if yas5014=6 then famedudebt=37500;
else if yas5014=7 then famedudebt=50001;
end;
end;

if yas5011=-1 or yas5011A=-1 or yas5013U=-1 or yas5013L=-1 or yas5014=-1 then famedudebt=-1;
if yas5011=-2 or yas5011A=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2 then famedudebt=-2;
if yas5011=-3 or yas5011A=-3 or yas5013U=-3 or yas5013L=-3 or yas5014=-3 or yas5012=-3 then famedudebt=-3;

*******************************************************************************************;

********************** Government loan *****************************;

govdebt=-4;
if yas5015=1 then do;
flag_govdebt=-4;
if yas5015A=1 & yas5016>=0 then govdebt=yas5016;
else if yas5015A=2 then do;
if yas5017L>=0 & yas5017U>=yas5017L then govdebt=(yas5017L+yas5017U)/2;
else govdebt=-3;
end;
if yas5015A not in (1,2) or yas5016 in (-1,-2) then do;
if 1<=yas5018<=7 then flag_govdebt=2;
if yas5018=1 then govdebt=500;
else if yas5018=2 then govdebt=1750;
else if yas5018=3 then govdebt=3750;
else if yas5018=4 then govdebt=7500;
else if yas5018=5 then govdebt=17500;
else if yas5018=6 then govdebt=37500;
else if yas5018=7 then govdebt=50001;
end;
end;

if yas5015=-1 or yas5015A=-1 or yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
if yas5015=-2 or yas5015A=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
if yas5015=-3 or yas5015A=-3 or yas5017U=-3 or yas5017L=-3 or yas5018=-3 or yas5016=-3 then govdebt=-3;


************ this is the end of govdebt. ********************************;
*/

**********************************************;
** If the respondent still owes loans to family or relatives, **;
** means has been loaned SDLI - famdebt.                      **;
**********************************************;

array famdebt (20) famdebt01-famdebt20;
array yas5080 (20) yas508001-yas508020;
array yas5082 (20) yas508201-yas508220;
array yas5084L (20) yas5084L01-yas5084L20;
array yas5084U (20) yas5084U01-yas5084U20;
array yas5086 (20) yas508601-yas508620;
array yas5170 (20) yas517001-yas517020;
array yas5172 (20) yas517201-yas517220;
array yas5174L (20) yas5174L01-yas5174L20;
array yas5174U (20) yas5174U01-yas5174U20;
array yas5176 (20) yas517601-yas517620;

array yas5074 (20) yas507401-yas507420;
array yas5164 (20) yas516401-yas516420;

do i=1 to dim(famdebt);
famdebt(i)=-4;
** R was NOT loaned money from family/friends at last assets interview **;
** but has been loaned SDLI. **;
if yas5040=1 then do;
FLAG_famdebt=1.1;
if yas5080(i)=1 & yas5082(i)>=0 then famdebt(i)=yas5082(i);
else if yas5080(i)=2 & yas5084L(i)>=0 & yas5084U(i)>=0
then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
if yas5080(i) not in (1,2) or yas5082(i) in (-1,-2) then do;
if 1<=yas5086(i)<=7 then FLAG_famdebt=2.1;
if yas5086(i)=1 then famdebt(i)=500;
else if yas5086(i)=2 then famdebt(i)=1750;
else if yas5086(i)=3 then famdebt(i)=3750;
else if yas5086(i)=4 then famdebt(i)=7500;
else if yas5086(i)=5 then famdebt(i)=17500;
else if yas5086(i)=6 then famdebt(i)=37500;
else if yas5086(i)=7 then famdebt(i)=50001;
end;
end;
if yas5040=-1 or yas5074(i)=-1 or yas5086(i)=-1 or yas5084L(i)=-1 or yas5084U(i)=-1
then famdebt(i)=-1;
if yas5040=-2 or yas5074(i)=-2 or yas5086(i)=-2 or yas5084L(i)=-2 or yas5084U(i)=-2
then famdebt(i)=-2;
if yas5040=-3 or yas5074(i)=-3 or yas5086(i)=-3 or yas5084L(i)=-3 or yas5084U(i)=-3 or yas5082(i)=-3
then famdebt(i)=-3;

** R was loaned money from family/friends at last assets interview **;
** and has also been loaned SDLI. **;
if yas5130=1 then do;
FLAG_famdebt=1.2;
if yas5170(i)=1 & yas5172(i)>=0 then famdebt(i)=yas5172(i);
else if yas5170(i)=2 & yas5174L(i)>=0 & yas5174U(i)>-0
then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
if yas5170(i) not in (1,2) or yas5172(i) in (-1,-2) then do;
if 1<=yas5176(i)<=7 then FLAG_famdebt=2.2;
if yas5176(i)=1 then famdebt(i)=500;
else if yas5176(i)=2 then famdebt(i)=1750;
else if yas5176(i)=3 then famdebt(i)=3750;
else if yas5176(i)=4 then famdebt(i)=7500;
else if yas5176(i)=5 then famdebt(i)=17500;
else if yas5176(i)=6 then famdebt(i)=37500;
else if yas5176(i)=7 then famdebt(i)=50001;
end;
end;
if yas5130=-1 or yas5164(i)=-1 or yas5176(i)=-1 or yas5174L(i)=-1 or yas5174U(i)=-1
then famdebt(i)=-1;
if yas5130=-2 or yas5164(i)=-2 or yas5176(i)=-2 or yas5174L(i)=-2 or yas5174U(i)=-2
then famdebt(i)=-2;
if yas5130=-3 or yas5164(i)=-3 or yas5176(i)=-3 or yas5174L(i)=-3 or yas5174U(i)=-3 or yas5172(i)=-3
then famdebt(i)=-3;
end;

***************** this is the end of family debts. ************************;


******* Checks for cases when R does not know who lent R the money. *******;
/*
who=0;
if yas5060=1|yas5062=1 then who=1;
if yas5150=1|yas5152=1 then who=2;
*/


***********************************************;
** If R or R's partner/spouse jointly have other debts from **;
** loans, credit cards, etc.                                                 **;
***********************************************;

othdebt=-4;
if yas5210=1 then do;
FLAG_othdebt=1;
if yas5220=1 & yas5222>=0 then othdebt=yas5222;
else if yas5220=2 & yas5224L>=0 & yas5224U>=0 then othdebt=(yas5224L+yas5224U)/2;
if yas5220 not in (1,2) or yas5222 in (-1,-2) then do;
if 1<=yas5226<=7 then FLAG_othdebt=2;
if yas5226=1 then othdebt=500;
else if yas5226=2 then othdebt=1750;
else if yas5226=3 then othdebt=3750;
else if yas5226=4 then othdebt=7500;
else if yas5226=5 then othdebt=17500;
else if yas5226=6 then othdebt=37500;
else if yas5226=7 then othdebt=50001;
end;
end;
if yas5210=-1 or yas5224L=-1 or yas5224U=-1 or yas5226=-1 then othdebt=-1;
if yas5210=-2 or yas5224L=-2 or yas5224U=-2 or yas5226=-2 then othdebt=-2;
if yas5210=-3 or yas5224L=-3 or yas5224U=-3 or yas5226=-3 or yas5222=-3 then othdebt=-3;

***************** this is the end of other debts. **************************;

***********************************;
** THIS IS THE END OF LIABILITIES. **;
***********************************;


****************************************;
** THIS IS THE END OF DATA CLEANING. **;
** THE FOLLOWING IS CALCULATION.     **;
****************************************;


*****************************************************;
** Compute the respondent's household net worth (hhworthY).      **;
** hhworthY=assets-liabilities. YAST-105 is the question              **;
** determining whether respondents are asked the assets question. **;
*****************************************************;

array varsasst (*) pvranch pvmbst pvmb pvst pvapt pvbuss othreal /*items of assets */
retdsav banksav bonds stocks pvcars pvfurn othsav;
array varsliab (*) mortgag resdebt othmort cardebt othdebt
famdebt01-famdebt20; /*items of liabilities */

array flgsasst (*) flag_pvranch flag_pvmbst flag_pvmb flag_pvst flag_pvapt
flag_pvbuss flag_othreal flag_retdsav flag_banksav flag_bonds
flag_stocks flag_pvcars flag_pvfurn flag_othsav;
array flgsliab (*) flag_mortgag flag_resdebt flag_othmort flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

array ahousedebt (*) mortgag resdebt othmort;
array afinance (*) retdsav banksav bonds stocks othsav;
array anonfinance (*) othreal pvcars pvfurn pvbuss;
array adebt (*) cardebt othdebt famdebt01-famdebt20;


array flgshsdt(*) flag_mortgag flag_resdebt flag_othmort;

array flgsfin(*) flag_retdsav flag_banksav flag_bonds flag_stocks flags_othsav;

array flgsnonfin(*) flag_othreal flag_pvcars flag_pvfurn flag_pvbuss;

array flgsdebt(*) flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

if yas1400=-4 then do;
hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;
end;

if (yas1400=0 or yas1400=1) then do;

hhworthY=0; assets=0; liabilities=0; housedebt=0;finance=0;nonfinance=0;debt=0;

do i=1 to dim(varsasst);
if varsasst(i) not in(-1,-2,-3,-4) then assets=assets+varsasst(i);
if varsasst(i) in (-1,-2,-3) then flgsasst(i)=-3;
end;

do i=1 to dim(varsliab);
if varsliab(i)>=0 then liabilities=liabilities+varsliab(i);
if varsliab(i) in (-1,-2,-3) then flgsliab(i)=-3;
end;

hhworthY=assets-liabilities;

do i=1 to dim(ahousedebt);
if ahousedebt(i)>=0 then housedebt=housedebt+ahousedebt(i);
if ahousedebt(i) in (-1,-2,-3) then flgshsdt(i)=-3;
end;
do i=1 to dim(afinance);
if afinance(i)>=0 then finance=finance+afinance(i);
if afinance(i) in (-1, -2, -3) then flgsfin(i)=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i) not in(-1,-2,-3,-4) then nonfinance=nonfinance+anonfinance(i);
if anonfinance(i) in (-1, -2, -3) then flgsnonfin(i)=-3;
end;
do i=1 to dim(adebt);
if adebt(i)>=0 then debt=debt+adebt(i);
if adebt(i) in (-1, -2, -3) then flgsdebt(i)=-3;
end;

end;


*** Code hhworthY as a valid skip for those who were not asked the assets questions;
if yas1400=-4 then do;
hhworthY=-4;
vskpHHY=1;
end;

*** Code hhworthY as an invalid skip for those who did not give valid responses;
do i=1 to dim(varsasst);
if varsasst(i)=-1 then do;
hhworthY=-1;
assets=-1;
invskpHHY=1;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-1 then do;
hhworthY=-1;
invskpHHY=1;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-2 then do;
hhworthY=-2;
assets=-2;
invskpHHY=2;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-2 then do;
hhworthY=-2;
invskpHHY=2;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-3 then do;
hhworthY=-3;
assets=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-3 then do;
hhworthY=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(ahousedebt);
if ahousedebt(i)=-1 then housedebt=-1;
else if ahousedebt(i)=-2 then housedebt=-2;
else if ahousedebt(i)=-3 then housedebt=-3;
end;
do i=1 to dim(afinance);
if afinance(i)=-1 then finance=-1;
else if afinance(i)=-2 then finance=-2;
else if afinance(i)=-3 then finance=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)=-1 then nonfinance=-1;
else if anonfinance(i)=-2 then nonfinance=-2;
else if anonfinance(i)=-3 then nonfinance=-3;
end;
do i=1 to dim(adebt);
if adebt(i)=-1 then debt=-1;
else if adebt(i)=-2 then debt=-2;
else if adebt(i)=-3 then debt=-3;
end;

hhworthY=round(hhworthY,1);
assets=round(assets,1);
housedebt=round(housedebt,1);
house_value=round(house_value,1);
finance=round(finance,1);
nonfinance=round(nonfinance,1);
debt=round(debt,1);


************* Change all the -1s, -2s to -3s. ***************;

array finalv(*) hhworthY assets housedebt house_value finance nonfinance debt;
do i=1 to dim(finalv);
if finalv(i) in (-1,-2) then finalv(i)=-3;
end;

run;

Return to top


Round 4

******************* Start of the Youth Asset Section (hhworthY) *******************;
** First create the following components of the hhworthY such as real estate, loans,                **;
** cars etc.Each subsection computes one item of the total asset of Youth Respondent            **;
** and his/her spouse or partner. Flag variables are created to indicate whether                       **;
** R/family received that asset item (FLAG_item in (1,2,-3)) and if so was the amount            **;
** computed directly from the amount reported by R (FLAG_item=1) or it was computed      **;
** from estimates given by R (FLAG_item=2) or it could not be computed (FLAG_item=-3). **;
*************************************************************************;

libname r4 "C:\My Documents\NLSY97\Round8\Data\r4";
data r4.age20r4;
set r4.r4_20;
round=4;




housing_type=-4;
house_value=-4;


****************************************************;
** If the respondent owns some land, its present value - pvranch. **;
****************************************************;

pvranch=-4;
*** If R alone or R and R's partner/spouse jointly own all of it. ***;
if yas1400=1 & (yas1610=1 or yas1610=2) then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas1860=1 & yas1862>=0 then pvranch=yas1862; /*how about lt 0?*/
else if yas1860=2 & yas1864L>=0 & yas1864U>=0 then do;
if yas1864U>=yas1864L then pvranch=(yas1864L+yas1864U)/2;
else pvranch=-3;
end;
if yas1860 not in (1,2) or yas1862 in (-1,-2) then do;
if 1<=yas1866<=7 then FLAG_pvranch=2;
if yas1866=1 then pvranch=12500;
else if yas1866=2 then pvranch=37500;
else if yas1866=3 then pvranch=75000;
else if yas1866=4 then pvranch=175000;
else if yas1866=5 then pvranch=375000;
else if yas1866=6 then pvranch=750000;
else if yas1866=7 then pvranch=1000001;
end;
end;


*** If R alone or R and R's partner/spouse jointly own part of it (100%). ***;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2140=1 & yas2142>=0 then pvranch=yas2142;
else if yas2140=2 & yas2144L>=0 & yas2144U>=0 then do;
if yas2144U>=yas2144L then pvranch=(yas2144L+yas2144U)/2;
else pvranch=-3;
end;
if yas2140 not in (1,2) or yas2142 in (-1,-2) then do;
if 1<=yas2146<=7 then FLAG_pvranch=2;
if yas2146=1 then pvranch=12500;
else if yas2146=2 then pvranch=37500;
else if yas2146=3 then pvranch=75000;
else if yas2146=4 then pvranch=175000;
else if yas2146=5 then pvranch=375000;
else if yas2146=6 then pvranch=750000;
else if yas2146=7 then pvranch=1000001;
end;
end;


** If R alone or R and R's partner/spouse jointly own part of it (< 100%) **;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120~=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2170=1 & yas2172>=0 then pvranch=yas2172;
else if yas2170=2 & yas2174L>=0 & yas2174U>=0 then do;
if yas2174U>=yas2174L then pvranch=(yas2174L+yas2174U)/2;
else pvranch=-3;
end;
if yas2170 not in (1,2) or yas2172 in (-1,-2) then do;
if 1<=yas2176<=7 then FLAG_pvranch=2;
if yas2176=1 then pvranch=12500;
else if yas2176=2 then pvranch=37500;
else if yas2176=3 then pvranch=75000;
else if yas2176=4 then pvranch=175000;
else if yas2176=5 then pvranch=375000;
else if yas2176=6 then pvranch=750000;
else if yas2176=7 then pvranch=1000001;
end;
end;

if yas1400=-1 or yas1610=-1
or yas1864L=-1 or yas1864U=-1 or yas1866=-1
or yas2144L=-1 or yas2144U=-1 or yas2146=-1
or yas2174L=-1 or yas2174U=-1 or yas2176=-1 then pvranch=-1;

if yas1400=-2 or yas1610=-2
or yas1864L=-2 or yas1864U=-2 or yas1866=-2
or yas2144L=-2 or yas2144U=-2 or yas2146=-2
or yas2174L=-2 or yas2174U=-2 or yas2176=-2 then pvranch=-2;

if yas1400=-3 or yas1610=-3
or yas1864L=-3 or yas1864U=-3 or yas1866=-3
or yas2144L=-3 or yas2144U=-3 or yas2146=-3
or yas2174L=-3 or yas2174U=-3 or yas2176=-3
or yas1862=-3 or yas2142=-3 or yas2172=-3 then pvranch=-3;

if flag_pvranch=1 then do;
housing_type=2;
house_value=pvranch;
end;

if yas1610=6 then do;
housing_type=6;
house_value=-4;
end;

***** this is the end of land part. *****;


******************************************************;
** If R alone or R and R's partner/spouse jointly own a mobile home **;
** and its site, its present value - pvmbst.                                          **;
******************************************************;

pvmbst=-4;
if yas2520 in (1,2) then do;
FLAG_pvmbst=1;
flagck_mbst=1;
if yas2550=1 & yas2552>=0 then pvmbst=yas2552;
else if yas2550=2 & yas2554L>=0 & yas2554U>=0 then do;
if yas2554U>=yas2554L then pvmbst=(yas2554L+yas2554U)/2;
else pvmbst=-3;
end;
if yas2550 not in (1,2) or yas2552 in (-1,-2) then do;
if 1<=yas2556<=7 then FLAG_pvmbst=2;
if yas2556=1 then pvmbst=500;
else if yas2556=2 then pvmbst=1750;
else if yas2556=3 then pvmbst=3750;
else if yas2556=4 then pvmbst=7500;
else if yas2556=5 then pvmbst=17500;
else if yas2556=6 then pvmbst=37500;
else if yas2556=7 then pvmbst=50001;
end;
end;
if yas2520=-1 or yas2554L=-1 or yas2554U=-1 or yas2556=-1 then pvmbst=-1;
if yas2520=-2 or yas2554L=-2 or yas2554U=-2 or yas2556=-2 then pvmbst=-2;
if yas2520=-3 or yas2554L=-3 or yas2554U=-3 or yas2556=-3 or yas2552=-3 then pvmbst=-3;

if flag_pvmbst=1 then do;
housing_type=4;
house_value=pvmbst;
end;

***** this is the end of mobile home & site. *****;


*******************************************************;
** If R alone or R and R's partner/spouse jointly own a mobile home, **;
** its present value - pvmb.                                                                **;
*******************************************************;

pvmb=-4;
if yas2520 in (3,4) then do;
FLAG_pvmb=1;
flagck_mb=1;
if yas2760=1 & yas2762>=0 then pvmb=yas2762;
else if yas2760=2 & yas2764L>=0 & yas2764U>=0 then do;
if yas2764U>=yas2764L then pvmb=(yas2764L+yas2764U)/2;
else pvmb=-3;
end;
if yas2760 not in (1,2) or yas2762 in (-1,-2) then do;
if 1<=yas2766<=7 then FLAG_pvmb=2;
if yas2766=1 then pvmb=12500;
else if yas2766=2 then pvmb=37500;
else if yas2766=3 then pvmb=75000;
else if yas2766=4 then pvmb=175000;
else if yas2766=5 then pvmb=375000;
else if yas2766=6 then pvmb=750000;
else if yas2766=7 then pvmb=1000001;
end;
end;
if yas2520=-1 or yas2764L=-1 or yas2764U=-1 or yas2766=-1 then pvmb=-1;
if yas2520=-2 or yas2764L=-2 or yas2764U=-2 or yas2766=-2 then pvmb=-2;
if yas2520=-3 or yas2764L=-3 or yas2764U=-3 or yas2766=-3 or yas2762=-3 then pvmb=-3;

if flag_pvmb=1 then do;
housing_type=3;
house_value=pvmb;
end;

***** this is the end of mobile home. *****;


**********************************************************;
** If R alone or R and R's partner/spouse jointly own a mobile home site, **;
** its present value - pvst.                                                                        **;
**********************************************************;

pvst=-4;
if yas2520 in (5,6) then do;
FLAG_pvst=1;
flagck_st=1;
if yas3010=1 & yas3012>=0 then pvst=yas3012;
else if yas3010=2 & yas3014L>=0 & yas3014U>=0 then do;
if yas3014U>=yas3014L then pvst=(yas3014L+yas3014U)/2;
else pvst=-3;
end;
if yas3010 not in (1,2) or yas3012 in (-1,-2) then do;
if 1<=yas3016<=7 then FLAG_pvst=2;
if yas3016=1 then pvst=12500;
else if yas3016=2 then pvst=57500;
else if yas3016=3 then pvst=75000;
else if yas3016=4 then pvst=175000;
else if yas3016=5 then pvst=575000;
else if yas3016=6 then pvst=750000;
else if yas3016=7 then pvst=1000001;
end;
end;
if yas2520=-1 or yas3014L=-1 or yas3014U=-1 or yas3016=-1 then pvst=-1;
if yas2520=-2 or yas3014L=-2 or yas3014U=-2 or yas3016=-2 then pvst=-2;
if yas2520=-3 or yas3014L=-3 or yas3014U=-3 or yas3016=-3 or yas3012=-3 then pvst=-3;

if flag_pvst=1 then do;
housing_type=5;
house_value=pvst;
end;

if yas2520=8 then do;
housing_type=6;
house_value=-4;
end;
***** this is the end of mobile home site. *****;

*****************************************************;
** THIS IS THE END OF MOBILE HOME & ITS SITE PART. **;
*****************************************************;


******************************************************;
** If R alone or R and R's partner/spouse jointly own an apartment, **;
** its present value - pvapt.                                                             **;
******************************************************;

pvapt=-4;
if yas3310 in (1,2) then do;
FLAG_pvapt=1;
flagck_apt=1;
if yas3380=1 & yas3382>=0 then pvapt=yas3382;
else if yas3380=2 & yas3384L>=0 & yas3384U>=0 then do;
if yas3384U>=yas3384L then pvapt=(yas3384L+yas3384U)/2;
else pvapt=-3;
end;
if yas3380 not in (1,2) or yas3382 in (-1,-2) then do;
if 1<=yas3386<=7 then FLAG_pvapt=2;
if yas3386=1 then pvapt=500;
else if yas3386=2 then pvapt=1750;
else if yas3386=3 then pvapt=3750;
else if yas3386=4 then pvapt=7500;
else if yas3386=5 then pvapt=17500;
else if yas3386=6 then pvapt=37500;
else if yas3386=7 then pvapt=50001;
end;
end;
if yas3310=-1 or yas3384L=-1 or yas3384U=-1 or yas3386=-1 then pvapt=-1;
if yas3310=-2 or yas3384L=-2 or yas3384U=-2 or yas3386=-2 then pvapt=-2;
if yas3310=-3 or yas3384L=-3 or yas3384U=-3 or yas3386=-3 or yas3382=-3 then pvapt=-3;

if yas3310 in (1,2) and yas3340=0 then housing_type=1;
else if yas3310 in (1,2) and yas3340=1 and yas3360=1 then housing_type=8;
else if yas3310 in (1,2) and yas3340=1 and yas3360=2 then housing_type=7;

if flag_pvapt=1 then house_value=pvapt;

if yas3310=4 then do;
housing_type=6;
house_value=-4;
end;

/*************************************************************/

/*************************************************************/

***** this is the end of apartment part. *****;


****************************************************;
** If R alone or R and R's partner/spouse jointly own a business,  **;
** partnership or professional practice, its present value - pvbuss. **;
****************************************************;

pvbuss=-4;
if yas4010 in (1,2) then do;
FLAG_pvbuss=1;
if yas4030=1 & yas4032 not in (-1,-2,-3,-4) then pvbuss=yas4032;
else if yas4030=2 then pvbuss=(yas4034L+yas4034U)/2;
if yas4030 not in (1,2) or yas4032 in (-1,-2) then do;
if 1<=yas4036<=7 then FLAG_pvbuss=2;
if yas4036=1 then pvbuss=12500;
else if yas4036=2 then pvbuss=37500;
else if yas4036=3 then pvbuss=75000;
else if yas4036=4 then pvbuss=175000;
else if yas4036=5 then pvbuss=375000;
else if yas4036=6 then pvbuss=750000;
else if yas4036=7 then pvbuss=1000001;
end;
end;
if yas4010=-1 or yas4034L=-1 or yas4034U=-1 or yas4036=-1 then pvbuss=-1;
if yas4010=-2 or yas4034L=-2 or yas4034U=-2 or yas4036=-2 then pvbuss=-2;
if yas4010=-3 or yas4034L=-3 or yas4034U=-3 or yas4036=-3 or yas4032=-3 then pvbuss=-3;

***** this is the end of business part. *****;


**************************************************;
** If R alone or R and R's partner/spouse jointly own a second **;
** real estate, its present value - othreal.                                   **;
**************************************************;

othreal=-4;
if yas4140 in (1,2) then do;
FLAG_othreal=1;
if yas4160=1 & yas4162>=0 then othreal=yas4162;
else if yas4160=2 & yas4164U>=0 & yas4164L>=0 then do;
if yas4164U>=yas4164L then othreal=(yas4164L+yas4164U)/2;
else othreal=-3;
end;
if yas4160 not in (1,2) or yas4162 in (-1,-2) then do;
if 1<=yas4166<=7 then FLAG_othreal=2;
if yas4166=1 then othreal=12500;
else if yas4166=2 then othreal=37500;
else if yas4166=3 then othreal=75000;
else if yas4166=4 then othreal=175000;
else if yas4166=5 then othreal=375000;
else if yas4166=6 then othreal=750000;
else if yas4166=7 then othreal=1000001;
end;
end;
if yas4140=-1 or yas4164L=-1 or yas4164U=-1 or yas4166=-1 then othreal=-1;
if yas4140=-2 or yas4164L=-2 or yas4164U=-2 or yas4166=-2 then othreal=-2;
if yas4140=-3 or yas4164L=-3 or yas4164U=-3 or yas4166=-3 or yas4162=-3 then othreal=-3;

***** this is the end of other real estate. *****;


*********************************************************;
** If R or R's partner/spouse have retirement plans or pensions - retdsav **;
*********************************************************;

retdsav=-4;
if yas4270 in (1,2,3) then do;
FLAG_retdsav=1;
if yas4290=1 & yas4292>=0 then retdsav=yas4292;
else if yas4290=2 & yas4294U>=0 & yas4294L>=0 then retdsav=(yas4294L+yas4294U)/2;
if yas4290 not in (1,2) or yas4292 in (-1,-2) then do;
if 1<=yas4296<=7 then FLAG_retdsav=2;
if yas4296=1 then retdsav=2500;
else if yas4296=2 then retdsav=7500;
else if yas4296=3 then retdsav=17500;
else if yas4296=4 then retdsav=37500;
else if yas4296=5 then retdsav=75000;
else if yas4296=6 then retdsav=175000;
else if yas4296=7 then retdsav=250001;
end;
end;
if yas4270=-1 or yas4294L=-1 or yas4294U=-1 or yas4296=-1 then retdsav=-1;
if yas4270=-2 or yas4294L=-2 or yas4294U=-2 or yas4296=-2 then retdsav=-2;
if yas4270=-3 or yas4294L=-3 or yas4294U=-3 or yas4296=-3 or yas4292=-3 then retdsav=-3;

***** this is the end of retirement plans. *****;


**************************************************;
** If R or R's partner/spouse have banksav in saving accounts, **;
** money market, funds,trusts, - banksav.                                **;
**************************************************;

banksav=-4;
if yas4400 in (1,2,3) then do;
FLAG_banksav=1;
if yas4420=1 & yas4422>=0 then banksav=yas4422;
else if yas4420=2 & yas4424U>=0 & yas4424L>=0 then do;
if yas4424U>=yas4424L then banksav=(yas4424L+yas4424U)/2;
else banksav=-3;
end;
if yas4420 not in (1,2) or yas4422 in (-1,-2) then do;
if 1<=yas4426<=7 then FLAG_banksav=2;
if yas4426=1 then banksav=500;
else if yas4426=2 then banksav=1750;
else if yas4426=3 then banksav=3750;
else if yas4426=4 then banksav=7500;
else if yas4426=5 then banksav=17500;
else if yas4426=6 then banksav=37500;
else if yas4426=7 then banksav=50001;
end;
end;
if yas4400=-1 or yas4424L=-1 or yas4424U=-2 or yas4426=-1 then banksav=-1;
if yas4400=-2 or yas4424L=-2 or yas4424U=-2 or yas4426=-2 then banksav=-2;
if yas4400=-3 or yas4424L=-3 or yas4424U=-3 or yas4426=-3 or yas4422=-3 then banksav=-3;

***** this is the end of bank savings. *****;


***********************************************************;
** If R or R's partner/spouse have other banksav in bonds or cds - bonds. **;
***********************************************************;

bonds=-4;
if yas4530 in (1,2,3) then do;
FLAG_bonds=1;
if yas4550=1 & yas4552>=0 then bonds=yas4552;
else if yas4550=2 & yas4554U>=0 & yas4554L>=0 then bonds=(yas4554L+yas4554U)/2;
if yas4550 not in (1,2) or yas4552 in (-1,-2) then do;
if 1<=yas4556<=7 then FLAG_bonds=2;
if yas4556=1 then bonds=500;
else if yas4556=2 then bonds=1750;
else if yas4556=3 then bonds=3750;
else if yas4556=4 then bonds=7500;
else if yas4556=5 then bonds=17500;
else if yas4556=6 then bonds=37500;
else if yas4556=7 then bonds=50001;
end;
end;
if yas4530=-1 or yas4554L=-1 or yas4554U=-1 or yas4556=-1 then bonds=-1;
if yas4530=-2 or yas4554L=-2 or yas4554U=-2 or yas4556=-2 then bonds=-2;
if yas4530=-3 or yas4554L=-3 or yas4554U=-3 or yas4556=-3 or yas4552=-3 then bonds=-3;

***** this is the end of bonds. *****;


*** If the respondent or his/her partner/spouse have stocks, mutual funds - stocks;

stocks=-4;
if yas4660 in (1,2,3) then do;
FLAG_stocks=1;
if yas4680=1 & yas4682>=0 then stocks=yas4682;
else if yas4680=2 & yas4684L>=0 & yas4684U>=0 then do;
if yas4684U>=yas4684L then stocks=(yas4684L+yas4684U)/2;
else stocks=-3;
end;
if yas4680 not in (1,2) or yas4682 in (-1,-2) then do;
if 1<=yas4686<=7 then FLAG_stocks=2;
if yas4686=1 then stocks=500;
else if yas4686=2 then stocks=1750;
else if yas4686=3 then stocks=3750;
else if yas4686=4 then stocks=7500;
else if yas4686=5 then stocks=17500;
else if yas4686=6 then stocks=37500;
else if yas4686=7 then stocks=50001;
end;
end;
if yas4660=-1 or yas4684L=-1 or yas4684U=-1 or yas4686=-1 then stocks=-1;
if yas4660=-2 or yas4684L=-2 or yas4684U=-2 or yas4686=-2 then stocks=-2;
if yas4660=-3 or yas4684L=-3 or yas4684U=-3 or yas4686=-3 or yas4682=-3 then stocks=-3;

***** this is the end of stocks. *****;


******************************************************;
** If the respondent alone or respondent and his/her partner/spouse **;
** jointly own vehicles, their present value - pvcars.                         **;
******************************************************;

pvcars=-4;
if yas4790 in (1,2,3) then do;
FLAG_pvcars=1;
if yas4810=1 & yas4812>=0 then pvcars=yas4812;
else if yas4810=2 & yas4814L>=0 & yas4814U>=0 then do;
if yas4814U>=yas4814L then pvcars=(yas4814L+yas4814U)/2;
else pvcars=-3;
end;
if yas4810 not in (1,2) or yas4812 in (-1,-2) then do;
if 1<=yas4816<=7 then FLAG_pvcars=2;
if yas4816=1 then pvcars=2500;
else if yas4816=2 then pvcars=7500;
else if yas4816=3 then pvcars=17500;
else if yas4816=4 then pvcars=37500;
else if yas4816=5 then pvcars=75000;
else if yas4816=6 then pvcars=175000;
else if yas4816=7 then pvcars=250001;
end;
end;
if yas4790=-1 or yas4814L=-1 or yas4814U=-1 or yas4816=-1 then pvcars=-1;
if yas4790=-2 or yas4814L=-2 or yas4814U=-2 or yas4816=-2 then pvcars=-2;
if yas4790=-3 or yas4814L=-3 or yas4814U=-3 or yas4816=-3 or yas4812=-3 then pvcars=-3;

***** this is the end of vehicles part. *****;


**************************************************;
** If R alone or R and R's partner/spouse jointly own furniture, **;
** its present value - pvfurn.                                                     **;
**************************************************;

pvfurn=-4;
if yas4870>-4 then FLAG_pvfurn=1;
if yas4870=1 then pvfurn=2500;
else if yas4870=2 then pvfurn=7500;
else if yas4870=3 then pvfurn=17500;
else if yas4870=4 then pvfurn=37500;
else if yas4870=5 then pvfurn=75000;
else if yas4870=6 then pvfurn=175000;
else if yas4870=7 then pvfurn=250001;
else if yas4870=-1 then pvfurn=-1;
else if yas4870=-2 then pvfurn=-2;
else if yas4870=-3 then pvfurn=-3;

***** this is the end of furniture part. *****;


*******************************************************;
** If R alone or R and R's partner/spouse jointly own other assets not **;
** mentioned before - othsav.                                                            **;
*******************************************************;

othsav=-4;
if yas4880 in (1,2,3) then do;
FLAG_othsav=1;
if yas4900=1 & yas4902>=0 then othsav=yas4902;
else if yas4900=2 & yas4904L>=0 & yas4904U>=0 then othsav=(yas4904L+yas4904U)/2;
if yas4900 not in (1,2) or yas4902 in (-1,-2) then do;
if 1<=yas4906<=7 then FLAG_othsav=2;
if yas4906=1 then othsav=2500;
else if yas4906=2 then othsav=7500;
else if yas4906=3 then othsav=17500;
else if yas4906=4 then othsav=37500;
else if yas4906=5 then othsav=75000;
else if yas4906=6 then othsav=175000;
else if yas4906=7 then othsav=250001;
end;
end;
if yas4880=-1 or yas4904L=-1 or yas4904U=-1 or yas4906=-1 then othsav=-1;
if yas4880=-2 or yas4904L=-2 or yas4904U=-2 or yas4906=-2 then othsav=-2;
if yas4880=-3 or yas4904L=-3 or yas4904U=-3 or yas4906=-3 or yas4902=-3 then othsav=-3;

***** this is the end of other savings. *****;



***********************************;
** THIS IS THE END OF ASSETS.        **;
** THE FOLLOWING IS LIABILITIES. **;
***********************************;



*****************************************************;
** If there is mortgage or land contract on the aforementioned land **;
** or property - mortgag.                                                              **;
*****************************************************;

mortgag=-4;
if yas3740 in (1,2) then do;
FLAG_mortgag=1;
if yas3750=1 & yas3752>=0 then mortgag=yas3752;
else if yas3750=2 & yas3754L>=0 & yas3754U>=0 then mortgag=(yas3754L+yas3754U)/2;
if yas3750 not in (1,2) or yas3752 in (-1,-2) then do;
if 1<=yas3756<=7 then FLAG_mortgag=2;
if yas3756=1 then mortgag=500;
else if yas3756=2 then mortgag=1750;
else if yas3756=3 then mortgag=3750;
else if yas3756=4 then mortgag=7500;
else if yas3756=5 then mortgag=17500;
else if yas3756=6 then mortgag=37500;
else if yas3756=7 then mortgag=50001;
end;
end;
if yas3740=-1 or yas3754L=-1 or yas3754U=-1 or yas3756=-1 then mortgag=-1;
if yas3740=-2 or yas3754L=-2 or yas3754U=-2 or yas3756=-2 then mortgag=-2;
if yas3740=-3 or yas3754L=-3 or yas3754U=-3 or yas3756=-3 or yas3752=-3 then mortgag=-3;

***** this is the end of mortgage part. *****;


****************************************************;
** If R or R's partner/spouse has unpaid loans from Round 7        **;
** (yas3840=1 & yas3850=1) or still owes loans taken SDLI on **;
** house (yas3860=1) then total amount owed - resdebt.             **;
****************************************************;

resdebt=-4;
if (yas3840=1 & yas3850=1) or yas3860=1 then do;
FLAG_resdebt=1;
if yas3880=1 & yas3882>=0 then resdebt=yas3882;
else if yas3880=2 & yas3884U>=0 & yas3884L>=0 then resdebt=(yas3884L+yas3884U)/2;
if yas3880 not in (1,2) or yas3882 in (-1,-2) then do;
if 1<=yas3886<=7 then FLAG_resdebt=2;
if yas3886=1 then resdebt=500;
else if yas3886=2 then resdebt=1750;
else if yas3886=3 then resdebt=3750;
else if yas3886=4 then resdebt=7500;
else if yas3886=5 then resdebt=17500;
else if yas3886=6 then resdebt=37500;
else if yas3886=7 then resdebt=50001;
end;
end;
if yas3850=-1 or yas3860=-1 or yas3884L=-1 or yas3884U=-1 or yas3886=-1
then resdebt=-1;
if yas3850=-2 or yas3860=-2 or yas3884L=-2 or yas3884U=-2 or yas3886=-2
then resdebt=-2;
if yas3850=-3 or yas3860=-3 or yas3884L=-3 or yas3884U=-3 or yas3886=-3 or yas3882=-3
then resdebt=-3;

***** this is the end of resdebt. *****;


***********************************************;
** If the respondent or his/her partner/spouse have second **;
** mortgages - othmort.                                                     **;
***********************************************;

othmort=-4;
if yas3910=1 then do;
FLAG_othmort=1;
if yas3920=1 & yas3922>=0 then othmort=yas3922;
else if yas3920=2 & yas3924U>=0 & yas3924L>=0 then othmort=(yas3924L+yas3924U)/2;
if yas3920 not in (1,2) or yas3922 in (-1,-2) then do;
if 1<=yas3926<=7 then FLAG_othmort=2;
if yas3926=1 then othmort=500;
else if yas3926=2 then othmort=1750;
else if yas3926=3 then othmort=3750;
else if yas3926=4 then othmort=7500;
else if yas3926=5 then othmort=17500;
else if yas3926=6 then othmort=37500;
else if yas3926=7 then othmort=50001;
end;
end;
if yas3910=-1 or yas3924L=-1 or yas3924U=-1 or yas3926=-1 then othmort=-1;
if yas3910=-2 or yas3924L=-2 or yas3924U=-2 or yas3926=-2 then othmort=-2;
if yas3910=-3 or yas3924L=-3 or yas3924U=-3 or yas3926=-3 or yas3922=-3 then othmort=-3;

***** this is the end of other mortgage. *****;


**********************************************************;
** If R or R's partner/spouse still owe money on these vehicles - cardebt. **;
**********************************************************;

cardebt=-4;
if yas4840>-4 then FLAG_cardebt=1;
if yas4840=1 & yas4842>=0 then cardebt=yas4842;
else if yas4840=2 & yas4844L>=0 & yas4844U>=0 then cardebt=(yas4844L+yas4844U)/2;
if yas4840 not in (1,2) or yas4842 in (-1,-2) then do;
if 1<=yas4846<=7 then FLAG_cardebt=2;
if yas4846=1 then cardebt=2500;
else if yas4846=2 then cardebt=7500;
else if yas4846=3 then cardebt=17500;
else if yas4846=4 then cardebt=37500;
else if yas4846=5 then cardebt=75000;
else if yas4846=6 then cardebt=175000;
else if yas4846=7 then cardebt=250001;
end;
if yas4790=-1 or yas4844L=-1 or yas4844U=-1 or yas4846=-1 then cardebt=-1;
if yas4790=-2 or yas4844L=-2 or yas4844U=-2 or yas4846=-2 then cardebt=-2;
if yas4790=-3 or yas4844L=-3 or yas4844U=-3 or yas4846=-3 or yas4842=-3 then cardebt=-3;

***** this is the end of car debt. *****;

/*
*************************famedudebt**********************************;

famedudebt=-4;
if yas5011=1 then do;
flag_famedudebt=1;
if yas5011A=1 & yas5012>=0 then famedudebt=yas5012;
else if yas5011A=2 then do;
if yas5013L>=0 & yas5013U>=yas5013L then famedudebt=(yas5013L+yas5013U)/2;
else famedudebt=-3;
end;
if yas5011A not in (1,2) or yas5012 in (-1,-2) then do;
if 1<=yas5014<=7 then flag_famedudebt=2;
if yas5014=1 then famedudebt=500;
else if yas5014=2 then famedudebt=1750;
else if yas5014=3 then famedudebt=3750;
else if yas5014=4 then famedudebt=7500;
else if yas5014=5 then famedudebt=17500;
else if yas5014=6 then famedudebt=37500;
else if yas5014=7 then famedudebt=50001;
end;
end;

if yas5011=-1 or yas5011A=-1 or yas5013U=-1 or yas5013L=-1 or yas5014=-1 then famedudebt=-1;
if yas5011=-2 or yas5011A=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2 then famedudebt=-2;
if yas5011=-3 or yas5011A=-3 or yas5013U=-3 or yas5013L=-3 or yas5014=-3 or yas5012=-3 then famedudebt=-3;

*******************************************************************************************;

********************** Government loan *****************************;

govdebt=-4;
if yas5015=1 then do;
flag_govdebt=-4;
if yas5015A=1 & yas5016>=0 then govdebt=yas5016;
else if yas5015A=2 then do;
if yas5017L>=0 & yas5017U>=yas5017L then govdebt=(yas5017L+yas5017U)/2;
else govdebt=-3;
end;
if yas5015A not in (1,2) or yas5016 in (-1,-2) then do;
if 1<=yas5018<=7 then flag_govdebt=2;
if yas5018=1 then govdebt=500;
else if yas5018=2 then govdebt=1750;
else if yas5018=3 then govdebt=3750;
else if yas5018=4 then govdebt=7500;
else if yas5018=5 then govdebt=17500;
else if yas5018=6 then govdebt=37500;
else if yas5018=7 then govdebt=50001;
end;
end;

if yas5015=-1 or yas5015A=-1 or yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
if yas5015=-2 or yas5015A=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
if yas5015=-3 or yas5015A=-3 or yas5017U=-3 or yas5017L=-3 or yas5018=-3 or yas5016=-3 then govdebt=-3;


************ this is the end of govdebt. ********************************;
*/

****************************************************************************;
*** If the respondent still owes loans to family or relatives, ***;
*** means has been loaned SDLI - famdebt. ***;
****************************************************************************;

array famdebt (20) famdebt01-famdebt20;
array yas5080 (20) yas508001-yas508020;
array yas5082 (20) yas508201-yas508220;
array yas5084L (20) yas5084L01-yas5084L20;
array yas5084U (20) yas5084U01-yas5084U20;
array yas5086 (20) yas508601-yas508620;
array yas5170 (20) yas517001-yas517020;
array yas5172 (20) yas517201-yas517220;
array yas5174L (20) yas5174L01-yas5174L20;
array yas5174U (20) yas5174U01-yas5174U20;
array yas5176 (20) yas517601-yas517620;

array yas5074 (20) yas507401-yas507420;
array yas5164 (20) yas516401-yas516420;

do i=1 to dim(famdebt);
famdebt(i)=-4;
** R was NOT loaned money from family/friends at last assets interview **;
** but has been loaned SDLI. **;
if yas5040=1 then do;
FLAG_famdebt=1.1;
if yas5080(i)=1 & yas5082(i)>=0 then famdebt(i)=yas5082(i);
else if yas5080(i)=2 & yas5084L(i)>=0 & yas5084U(i)>=0
then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
if yas5080(i) not in (1,2) or yas5082(i) in (-1,-2) then do;
if 1<=yas5086(i)<=7 then FLAG_famdebt=2.1;
if yas5086(i)=1 then famdebt(i)=500;
else if yas5086(i)=2 then famdebt(i)=1750;
else if yas5086(i)=3 then famdebt(i)=3750;
else if yas5086(i)=4 then famdebt(i)=7500;
else if yas5086(i)=5 then famdebt(i)=17500;
else if yas5086(i)=6 then famdebt(i)=37500;
else if yas5086(i)=7 then famdebt(i)=50001;
end;
end;
if yas5040=-1 or yas5074(i)=-1 or yas5086(i)=-1 or yas5084L(i)=-1 or yas5084U(i)=-1
then famdebt(i)=-1;
if yas5040=-2 or yas5074(i)=-2 or yas5086(i)=-2 or yas5084L(i)=-2 or yas5084U(i)=-2
then famdebt(i)=-2;
if yas5040=-3 or yas5074(i)=-3 or yas5086(i)=-3 or yas5084L(i)=-3 or yas5084U(i)=-3 or yas5082(i)=-3
then famdebt(i)=-3;

** R was loaned money from family/friends at last assets interview **;
** and has also been loaned SDLI. **;
if yas5130=1 then do;
FLAG_famdebt=1.2;
if yas5170(i)=1 & yas5172(i)>=0 then famdebt(i)=yas5172(i);
else if yas5170(i)=2 & yas5174L(i)>=0 & yas5174U(i)>-0
then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
if yas5170(i) not in (1,2) or yas5172(i) in (-1,-2) then do;
if 1<=yas5176(i)<=7 then FLAG_famdebt=2.2;
if yas5176(i)=1 then famdebt(i)=500;
else if yas5176(i)=2 then famdebt(i)=1750;
else if yas5176(i)=3 then famdebt(i)=3750;
else if yas5176(i)=4 then famdebt(i)=7500;
else if yas5176(i)=5 then famdebt(i)=17500;
else if yas5176(i)=6 then famdebt(i)=37500;
else if yas5176(i)=7 then famdebt(i)=50001;
end;
end;
if yas5130=-1 or yas5164(i)=-1 or yas5176(i)=-1 or yas5174L(i)=-1 or yas5174U(i)=-1
then famdebt(i)=-1;
if yas5130=-2 or yas5164(i)=-2 or yas5176(i)=-2 or yas5174L(i)=-2 or yas5174U(i)=-2
then famdebt(i)=-2;
if yas5130=-3 or yas5164(i)=-3 or yas5176(i)=-3 or yas5174L(i)=-3 or yas5174U(i)=-3 or yas5172(i)=-3
then famdebt(i)=-3;
end;

***************** this is the end of family debts. ************************;



******* Checks for cases when R does not know who lent R the money. *******;
/*
who=0;
if yas5060=1|yas5062=1 then who=1;
if yas5150=1|yas5152=1 then who=2;
*/


****************************************************************;
*** If R or R's partner/spouse jointly have other debts from ***;
*** loans, credit cards, etc. ***;
****************************************************************;

othdebt=-4;
if yas5210=1 then do;
FLAG_othdebt=1;
if yas5220=1 & yas5222>=0 then othdebt=yas5222;
else if yas5220=2 & yas5224L>=0 & yas5224U>=0 then othdebt=(yas5224L+yas5224U)/2;
if yas5220 not in (1,2) or yas5222 in (-1,-2) then do;
if 1<=yas5226<=7 then FLAG_othdebt=2;
if yas5226=1 then othdebt=500;
else if yas5226=2 then othdebt=1750;
else if yas5226=3 then othdebt=3750;
else if yas5226=4 then othdebt=7500;
else if yas5226=5 then othdebt=17500;
else if yas5226=6 then othdebt=37500;
else if yas5226=7 then othdebt=50001;
end;
end;
if yas5210=-1 or yas5224L=-1 or yas5224U=-1 or yas5226=-1 then othdebt=-1;
if yas5210=-2 or yas5224L=-2 or yas5224U=-2 or yas5226=-2 then othdebt=-2;
if yas5210=-3 or yas5224L=-3 or yas5224U=-3 or yas5226=-3 or yas5222=-3 then othdebt=-3;

***************** this is the end of other debts. **************************;

****************************************************************************;
**** THIS IS THE END OF LIABILITIES. ****;
****************************************************************************;




******************************************************************;
***** THIS IS THE END OF DATA CLEANING. *****;
***** THE FOLLOWING IS CALCULATION. *****;
******************************************************************;


************************************************************************;
*** Compute the respondent's household net worth (hhworthY). ***;
*** hhworthY=assets-liabilities. YAST-105 is the question ***;
*** determining whether respondents are asked the assets question. ***;
************************************************************************;

array varsasst (*) pvranch pvmbst pvmb pvst pvapt pvbuss othreal /*items of assets */
retdsav banksav bonds stocks pvcars pvfurn othsav;
array varsliab (*) mortgag resdebt othmort cardebt othdebt
famdebt01-famdebt20; /*items of liabilities */

array flgsasst (*) flag_pvranch flag_pvmbst flag_pvmb flag_pvst flag_pvapt
flag_pvbuss flag_othreal flag_retdsav flag_banksav flag_bonds
flag_stocks flag_pvcars flag_pvfurn flag_othsav;
array flgsliab (*) flag_mortgag flag_resdebt flag_othmort flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

array ahousedebt (*) mortgag resdebt othmort;
array afinance (*) retdsav banksav bonds stocks othsav;
array anonfinance (*) othreal pvcars pvfurn pvbuss;
array adebt (*) cardebt othdebt famdebt01-famdebt20;


array flgshsdt(*) flag_mortgag flag_resdebt flag_othmort;

array flgsfin(*) flag_retdsav flag_banksav flag_bonds flag_stocks flags_othsav;

array flgsnonfin(*) flag_othreal flag_pvcars flag_pvfurn flag_pvbuss;

array flgsdebt(*) flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

if yas1400=-4 then do;
hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;
end;

if (yas1400=0 or yas1400=1) then do;

hhworthY=0; assets=0; liabilities=0; housedebt=0;finance=0;nonfinance=0;debt=0;

do i=1 to dim(varsasst);
if varsasst(i) not in(-1,-2,-3,-4) then assets=assets+varsasst(i);
if varsasst(i) in (-1,-2,-3) then flgsasst(i)=-3;
end;

do i=1 to dim(varsliab);
if varsliab(i)>=0 then liabilities=liabilities+varsliab(i);
if varsliab(i) in (-1,-2,-3) then flgsliab(i)=-3;
end;

hhworthY=assets-liabilities;

do i=1 to dim(ahousedebt);
if ahousedebt(i)>=0 then housedebt=housedebt+ahousedebt(i);
if ahousedebt(i) in (-1,-2,-3) then flgshsdt(i)=-3;
end;
do i=1 to dim(afinance);
if afinance(i)>=0 then finance=finance+afinance(i);
if afinance(i) in (-1, -2, -3) then flgsfin(i)=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i) not in(-1,-2,-3,-4) then nonfinance=nonfinance+anonfinance(i);
if anonfinance(i) in (-1, -2, -3) then flgsnonfin(i)=-3;
end;
do i=1 to dim(adebt);
if adebt(i)>=0 then debt=debt+adebt(i);
if adebt(i) in (-1, -2, -3) then flgsdebt(i)=-3;
end;

end;




*** Code hhworthY as a valid skip for those who were not asked the assets questions;
if yas1400=-4 then do;
hhworthY=-4;
vskpHHY=1;
end;

*** Code hhworthY as an invalid skip for those who did not give valid responses;
do i=1 to dim(varsasst);
if varsasst(i)=-1 then do;
hhworthY=-1;
assets=-1;
invskpHHY=1;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-1 then do;
hhworthY=-1;
invskpHHY=1;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-2 then do;
hhworthY=-2;
assets=-2;
invskpHHY=2;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-2 then do;
hhworthY=-2;
invskpHHY=2;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-3 then do;
hhworthY=-3;
assets=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-3 then do;
hhworthY=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(ahousedebt);
if ahousedebt(i)=-1 then housedebt=-1;
else if ahousedebt(i)=-2 then housedebt=-2;
else if ahousedebt(i)=-3 then housedebt=-3;
end;
do i=1 to dim(afinance);
if afinance(i)=-1 then finance=-1;
else if afinance(i)=-2 then finance=-2;
else if afinance(i)=-3 then finance=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)=-1 then nonfinance=-1;
else if anonfinance(i)=-2 then nonfinance=-2;
else if anonfinance(i)=-3 then nonfinance=-3;
end;
do i=1 to dim(adebt);
if adebt(i)=-1 then debt=-1;
else if adebt(i)=-2 then debt=-2;
else if adebt(i)=-3 then debt=-3;
end;

hhworthY=round(hhworthY,1);
assets=round(assets,1);
housedebt=round(housedebt,1);
house_value=round(house_value,1);
finance=round(finance,1);
nonfinance=round(nonfinance,1);
debt=round(debt,1);


************* Change all the -1s, -2s to -3s. ***************;

array finalv(*) hhworthY assets housedebt house_value finance nonfinance debt;
do i=1 to dim(finalv);
if finalv(i) in (-1,-2) then finalv(i)=-3;
end;

run;

Return to top


Round 5

Variables Created:

******************* Start of the Youth Asset Section (hhworthY) ***********************;
* *;
* First create the following components of the hhworthY such as real estate, loans, *;
* cars etc.Each subsection computes one item of the total asset of Youth Respondent *;
* and his/her spouse or partner. Flag variables are created to indicate whether *;
* R/family received that asset item (FLAG_item in (1,2,-3)) and if so was the amount *;
* computed directly from the amount reported by R (FLAG_item=1) or it was computed *;
* from estimates given by R (FLAG_item=2) or it could not be computed (FLAG_item=-3). *;
***************************************************************************************;

libname r5 "C:\My Documents\NLSY97\Round8\Data\r5";
data r5.age20r5;
set r5.r5_20;
round=5;




housing_type=-4;
house_value=-4;


**********************************************************************;
*** If the respondent owns some land, its present value - pvranch. ***;
**********************************************************************;

pvranch=-4;
*** If R alone or R and R's partner/spouse jointly own all of it. ***;
if yas1400=1 & (yas1610=1 or yas1610=2) then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas1860=1 & yas1862>=0 then pvranch=yas1862; /*how about lt 0?*/
else if yas1860=2 & yas1864L>=0 & yas1864U>=0 then do;
if yas1864U>=yas1864L then pvranch=(yas1864L+yas1864U)/2;
else pvranch=-3;
end;
if yas1860 not in (1,2) or yas1862 in (-1,-2) then do;
if 1<=yas1866<=7 then FLAG_pvranch=2;
if yas1866=1 then pvranch=12500;
else if yas1866=2 then pvranch=37500;
else if yas1866=3 then pvranch=75000;
else if yas1866=4 then pvranch=175000;
else if yas1866=5 then pvranch=375000;
else if yas1866=6 then pvranch=750000;
else if yas1866=7 then pvranch=1000001;
end;
end;


*** If R alone or R and R's partner/spouse jointly own part of it (100%). ***;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2140=1 & yas2142>=0 then pvranch=yas2142;
else if yas2140=2 & yas2144L>=0 & yas2144U>=0 then do;
if yas2144U>=yas2144L then pvranch=(yas2144L+yas2144U)/2;
else pvranch=-3;
end;
if yas2140 not in (1,2) or yas2142 in (-1,-2) then do;
if 1<=yas2146<=7 then FLAG_pvranch=2;
if yas2146=1 then pvranch=12500;
else if yas2146=2 then pvranch=37500;
else if yas2146=3 then pvranch=75000;
else if yas2146=4 then pvranch=175000;
else if yas2146=5 then pvranch=375000;
else if yas2146=6 then pvranch=750000;
else if yas2146=7 then pvranch=1000001;
end;
end;


** If R alone or R and R's partner/spouse jointly own part of it (< 100%) **;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120~=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2170=1 & yas2172>=0 then pvranch=yas2172;
else if yas2170=2 & yas2174L>=0 & yas2174U>=0 then do;
if yas2174U>=yas2174L then pvranch=(yas2174L+yas2174U)/2;
else pvranch=-3;
end;
if yas2170 not in (1,2) or yas2172 in (-1,-2) then do;
if 1<=yas2176<=7 then FLAG_pvranch=2;
if yas2176=1 then pvranch=12500;
else if yas2176=2 then pvranch=37500;
else if yas2176=3 then pvranch=75000;
else if yas2176=4 then pvranch=175000;
else if yas2176=5 then pvranch=375000;
else if yas2176=6 then pvranch=750000;
else if yas2176=7 then pvranch=1000001;
end;
end;

if yas1400=-1 or yas1610=-1
or yas1864L=-1 or yas1864U=-1 or yas1866=-1
or yas2144L=-1 or yas2144U=-1 or yas2146=-1
or yas2174L=-1 or yas2174U=-1 or yas2176=-1 then pvranch=-1;

if yas1400=-2 or yas1610=-2
or yas1864L=-2 or yas1864U=-2 or yas1866=-2
or yas2144L=-2 or yas2144U=-2 or yas2146=-2
or yas2174L=-2 or yas2174U=-2 or yas2176=-2 then pvranch=-2;

if yas1400=-3 or yas1610=-3
or yas1864L=-3 or yas1864U=-3 or yas1866=-3
or yas2144L=-3 or yas2144U=-3 or yas2146=-3
or yas2174L=-3 or yas2174U=-3 or yas2176=-3
or yas1862=-3 or yas2142=-3 or yas2172=-3 then pvranch=-3;

if flag_pvranch=1 then do;
housing_type=2;
house_value=pvranch;
end;

if yas1610=6 then do;
housing_type=6;
house_value=-4;
end;

********* this is the end of land part. ***************;


************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home ***;
*** and its site, its present value - pvmbst. ***;
************************************************************************;

pvmbst=-4;
if yas2520 in (1,2) then do;
FLAG_pvmbst=1;
flagck_mbst=1;
if yas2550=1 & yas2552>=0 then pvmbst=yas2552;
else if yas2550=2 & yas2554L>=0 & yas2554U>=0 then do;
if yas2554U>=yas2554L then pvmbst=(yas2554L+yas2554U)/2;
else pvmbst=-3;
end;
if yas2550 not in (1,2) or yas2552 in (-1,-2) then do;
if 1<=yas2556<=7 then FLAG_pvmbst=2;
if yas2556=1 then pvmbst=500;
else if yas2556=2 then pvmbst=1750;
else if yas2556=3 then pvmbst=3750;
else if yas2556=4 then pvmbst=7500;
else if yas2556=5 then pvmbst=17500;
else if yas2556=6 then pvmbst=37500;
else if yas2556=7 then pvmbst=50001;
end;
end;
if yas2520=-1 or yas2554L=-1 or yas2554U=-1 or yas2556=-1 then pvmbst=-1;
if yas2520=-2 or yas2554L=-2 or yas2554U=-2 or yas2556=-2 then pvmbst=-2;
if yas2520=-3 or yas2554L=-3 or yas2554U=-3 or yas2556=-3 or yas2552=-3 then pvmbst=-3;

if flag_pvmbst=1 then do;
housing_type=4;
house_value=pvmbst;
end;

***** this is the end of mobile home & site. *****;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home, ***;
*** its present value - pvmb. ***;
*************************************************************************;

pvmb=-4;
if yas2520 in (3,4) then do;
FLAG_pvmb=1;
flagck_mb=1;
if yas2760=1 & yas2762>=0 then pvmb=yas2762;
else if yas2760=2 & yas2764L>=0 & yas2764U>=0 then do;
if yas2764U>=yas2764L then pvmb=(yas2764L+yas2764U)/2;
else pvmb=-3;
end;
if yas2760 not in (1,2) or yas2762 in (-1,-2) then do;
if 1<=yas2766<=7 then FLAG_pvmb=2;
if yas2766=1 then pvmb=12500;
else if yas2766=2 then pvmb=37500;
else if yas2766=3 then pvmb=75000;
else if yas2766=4 then pvmb=175000;
else if yas2766=5 then pvmb=375000;
else if yas2766=6 then pvmb=750000;
else if yas2766=7 then pvmb=1000001;
end;
end;
if yas2520=-1 or yas2764L=-1 or yas2764U=-1 or yas2766=-1 then pvmb=-1;
if yas2520=-2 or yas2764L=-2 or yas2764U=-2 or yas2766=-2 then pvmb=-2;
if yas2520=-3 or yas2764L=-3 or yas2764U=-3 or yas2766=-3 or yas2762=-3 then pvmb=-3;

if flag_pvmb=1 then do;
housing_type=3;
house_value=pvmb;
end;

******* this is the end of mobile home. ********;


******************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home site, ***;
*** its present value - pvst. ***;
******************************************************************************;

pvst=-4;
if yas2520 in (5,6) then do;
FLAG_pvst=1;
flagck_st=1;
if yas3010=1 & yas3012>=0 then pvst=yas3012;
else if yas3010=2 & yas3014L>=0 & yas3014U>=0 then do;
if yas3014U>=yas3014L then pvst=(yas3014L+yas3014U)/2;
else pvst=-3;
end;
if yas3010 not in (1,2) or yas3012 in (-1,-2) then do;
if 1<=yas3016<=7 then FLAG_pvst=2;
if yas3016=1 then pvst=12500;
else if yas3016=2 then pvst=57500;
else if yas3016=3 then pvst=75000;
else if yas3016=4 then pvst=175000;
else if yas3016=5 then pvst=575000;
else if yas3016=6 then pvst=750000;
else if yas3016=7 then pvst=1000001;
end;
end;
if yas2520=-1 or yas3014L=-1 or yas3014U=-1 or yas3016=-1 then pvst=-1;
if yas2520=-2 or yas3014L=-2 or yas3014U=-2 or yas3016=-2 then pvst=-2;
if yas2520=-3 or yas3014L=-3 or yas3014U=-3 or yas3016=-3 or yas3012=-3 then pvst=-3;

if flag_pvst=1 then do;
housing_type=5;
house_value=pvst;
end;

if yas2520=8 then do;
housing_type=6;
house_value=-4;
end;
******** this is the end of mobile home site. ********;

*******************************************************;
*** THIS IS THE END OF MOBILE HOME & ITS SITE PART. ***;
*******************************************************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own an apartment, ***;
*** its present value - pvapt. ***;
*************************************************************************;

pvapt=-4;
if yas3310 in (1,2) then do;
FLAG_pvapt=1;
flagck_apt=1;
if yas3380=1 & yas3382>=0 then pvapt=yas3382;
else if yas3380=2 & yas3384L>=0 & yas3384U>=0 then do;
if yas3384U>=yas3384L then pvapt=(yas3384L+yas3384U)/2;
else pvapt=-3;
end;
if yas3380 not in (1,2) or yas3382 in (-1,-2) then do;
if 1<=yas3386<=7 then FLAG_pvapt=2;
if yas3386=1 then pvapt=500;
else if yas3386=2 then pvapt=1750;
else if yas3386=3 then pvapt=3750;
else if yas3386=4 then pvapt=7500;
else if yas3386=5 then pvapt=17500;
else if yas3386=6 then pvapt=37500;
else if yas3386=7 then pvapt=50001;
end;
end;
if yas3310=-1 or yas3384L=-1 or yas3384U=-1 or yas3386=-1 then pvapt=-1;
if yas3310=-2 or yas3384L=-2 or yas3384U=-2 or yas3386=-2 then pvapt=-2;
if yas3310=-3 or yas3384L=-3 or yas3384U=-3 or yas3386=-3 or yas3382=-3 then pvapt=-3;

if yas3310 in (1,2) and yas3340=0 then housing_type=1;
else if yas3310 in (1,2) and yas3340=1 and yas3360=1 then housing_type=8;
else if yas3310 in (1,2) and yas3340=1 and yas3360=2 then housing_type=7;

if flag_pvapt=1 then house_value=pvapt;

if yas3310=4 then do;
housing_type=6;
house_value=-4;
end;

/*************************************************************/

/*************************************************************/

********** this is the end of apartment part. *********************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a business, ***;
*** partnership or professional practice, its present value - pvbuss. ***;
*************************************************************************;

pvbuss=-4;
if yas4010 in (1,2) then do;
FLAG_pvbuss=1;
if yas4030=1 & yas4032 not in (-1,-2,-3,-4) then pvbuss=yas4032;
else if yas4030=2 then pvbuss=(yas4034L+yas4034U)/2;
if yas4030 not in (1,2) or yas4032 in (-1,-2) then do;
if 1<=yas4036<=7 then FLAG_pvbuss=2;
if yas4036=1 then pvbuss=12500;
else if yas4036=2 then pvbuss=37500;
else if yas4036=3 then pvbuss=75000;
else if yas4036=4 then pvbuss=175000;
else if yas4036=5 then pvbuss=375000;
else if yas4036=6 then pvbuss=750000;
else if yas4036=7 then pvbuss=1000001;
end;
end;
if yas4010=-1 or yas4034L=-1 or yas4034U=-1 or yas4036=-1 then pvbuss=-1;
if yas4010=-2 or yas4034L=-2 or yas4034U=-2 or yas4036=-2 then pvbuss=-2;
if yas4010=-3 or yas4034L=-3 or yas4034U=-3 or yas4036=-3 or yas4032=-3 then pvbuss=-3;

********* this is the end of business part. *****************;


*******************************************************************;
*** If R alone or R and R's partner/spouse jointly own a second ***;
*** real estate, its present value - othreal. ***;
*******************************************************************;

othreal=-4;
if yas4140 in (1,2) then do;
FLAG_othreal=1;
if yas4160=1 & yas4162>=0 then othreal=yas4162;
else if yas4160=2 & yas4164U>=0 & yas4164L>=0 then do;
if yas4164U>=yas4164L then othreal=(yas4164L+yas4164U)/2;
else othreal=-3;
end;
if yas4160 not in (1,2) or yas4162 in (-1,-2) then do;
if 1<=yas4166<=7 then FLAG_othreal=2;
if yas4166=1 then othreal=12500;
else if yas4166=2 then othreal=37500;
else if yas4166=3 then othreal=75000;
else if yas4166=4 then othreal=175000;
else if yas4166=5 then othreal=375000;
else if yas4166=6 then othreal=750000;
else if yas4166=7 then othreal=1000001;
end;
end;
if yas4140=-1 or yas4164L=-1 or yas4164U=-1 or yas4166=-1 then othreal=-1;
if yas4140=-2 or yas4164L=-2 or yas4164U=-2 or yas4166=-2 then othreal=-2;
if yas4140=-3 or yas4164L=-3 or yas4164U=-3 or yas4166=-3 or yas4162=-3 then othreal=-3;

**************** this is the end of other real estate. ********************;


******************************************************************************;
*** If R or R's partner/spouse have retirement plans or pensions - retdsav ***;
******************************************************************************;

retdsav=-4;
if yas4270 in (1,2,3) then do;
FLAG_retdsav=1;
if yas4290=1 & yas4292>=0 then retdsav=yas4292;
else if yas4290=2 & yas4294U>=0 & yas4294L>=0 then retdsav=(yas4294L+yas4294U)/2;
if yas4290 not in (1,2) or yas4292 in (-1,-2) then do;
if 1<=yas4296<=7 then FLAG_retdsav=2;
if yas4296=1 then retdsav=2500;
else if yas4296=2 then retdsav=7500;
else if yas4296=3 then retdsav=17500;
else if yas4296=4 then retdsav=37500;
else if yas4296=5 then retdsav=75000;
else if yas4296=6 then retdsav=175000;
else if yas4296=7 then retdsav=250001;
end;
end;
if yas4270=-1 or yas4294L=-1 or yas4294U=-1 or yas4296=-1 then retdsav=-1;
if yas4270=-2 or yas4294L=-2 or yas4294U=-2 or yas4296=-2 then retdsav=-2;
if yas4270=-3 or yas4294L=-3 or yas4294U=-3 or yas4296=-3 or yas4292=-3 then retdsav=-3;

******** this is the end of retirement plans. ****************;


*******************************************************************;
*** If R or R's partner/spouse have banksav in saving accounts, ***;
*** money market, funds,trusts, - banksav. ***;
*******************************************************************;

banksav=-4;
if yas4400 in (1,2,3) then do;
FLAG_banksav=1;
if yas4420=1 & yas4422>=0 then banksav=yas4422;
else if yas4420=2 & yas4424U>=0 & yas4424L>=0 then do;
if yas4424U>=yas4424L then banksav=(yas4424L+yas4424U)/2;
else banksav=-3;
end;
if yas4420 not in (1,2) or yas4422 in (-1,-2) then do;
if 1<=yas4426<=7 then FLAG_banksav=2;
if yas4426=1 then banksav=500;
else if yas4426=2 then banksav=1750;
else if yas4426=3 then banksav=3750;
else if yas4426=4 then banksav=7500;
else if yas4426=5 then banksav=17500;
else if yas4426=6 then banksav=37500;
else if yas4426=7 then banksav=50001;
end;
end;
if yas4400=-1 or yas4424L=-1 or yas4424U=-2 or yas4426=-1 then banksav=-1;
if yas4400=-2 or yas4424L=-2 or yas4424U=-2 or yas4426=-2 then banksav=-2;
if yas4400=-3 or yas4424L=-3 or yas4424U=-3 or yas4426=-3 or yas4422=-3 then banksav=-3;

************* this is the end of bank savings. ****************;


******************************************************************************;
*** If R or R's partner/spouse have other banksav in bonds or cds - bonds. ***;
******************************************************************************;

bonds=-4;
if yas4530 in (1,2,3) then do;
FLAG_bonds=1;
if yas4550=1 & yas4552>=0 then bonds=yas4552;
else if yas4550=2 & yas4554U>=0 & yas4554L>=0 then bonds=(yas4554L+yas4554U)/2;
if yas4550 not in (1,2) or yas4552 in (-1,-2) then do;
if 1<=yas4556<=7 then FLAG_bonds=2;
if yas4556=1 then bonds=500;
else if yas4556=2 then bonds=1750;
else if yas4556=3 then bonds=3750;
else if yas4556=4 then bonds=7500;
else if yas4556=5 then bonds=17500;
else if yas4556=6 then bonds=37500;
else if yas4556=7 then bonds=50001;
end;
end;
if yas4530=-1 or yas4554L=-1 or yas4554U=-1 or yas4556=-1 then bonds=-1;
if yas4530=-2 or yas4554L=-2 or yas4554U=-2 or yas4556=-2 then bonds=-2;
if yas4530=-3 or yas4554L=-3 or yas4554U=-3 or yas4556=-3 or yas4552=-3 then bonds=-3;

***************** this is the end of bonds. **********************;


*** If the respondent or his/her partner/spouse have stocks, mutual funds - stocks;

stocks=-4;
if yas4660 in (1,2,3) then do;
FLAG_stocks=1;
if yas4680=1 & yas4682>=0 then stocks=yas4682;
else if yas4680=2 & yas4684L>=0 & yas4684U>=0 then do;
if yas4684U>=yas4684L then stocks=(yas4684L+yas4684U)/2;
else stocks=-3;
end;
if yas4680 not in (1,2) or yas4682 in (-1,-2) then do;
if 1<=yas4686<=7 then FLAG_stocks=2;
if yas4686=1 then stocks=500;
else if yas4686=2 then stocks=1750;
else if yas4686=3 then stocks=3750;
else if yas4686=4 then stocks=7500;
else if yas4686=5 then stocks=17500;
else if yas4686=6 then stocks=37500;
else if yas4686=7 then stocks=50001;
end;
end;
if yas4660=-1 or yas4684L=-1 or yas4684U=-1 or yas4686=-1 then stocks=-1;
if yas4660=-2 or yas4684L=-2 or yas4684U=-2 or yas4686=-2 then stocks=-2;
if yas4660=-3 or yas4684L=-3 or yas4684U=-3 or yas4686=-3 or yas4682=-3 then stocks=-3;

****************** this is the end of stocks. ***********************;


************************************************************************;
*** If the respondent alone or respondent and his/her partner/spouse ***;
*** jointly own vehicles, their present value - pvcars. ***;
************************************************************************;

pvcars=-4;
if yas4790 in (1,2,3) then do;
FLAG_pvcars=1;
if yas4810=1 & yas4812>=0 then pvcars=yas4812;
else if yas4810=2 & yas4814L>=0 & yas4814U>=0 then do;
if yas4814U>=yas4814L then pvcars=(yas4814L+yas4814U)/2;
else pvcars=-3;
end;
if yas4810 not in (1,2) or yas4812 in (-1,-2) then do;
if 1<=yas4816<=7 then FLAG_pvcars=2;
if yas4816=1 then pvcars=2500;
else if yas4816=2 then pvcars=7500;
else if yas4816=3 then pvcars=17500;
else if yas4816=4 then pvcars=37500;
else if yas4816=5 then pvcars=75000;
else if yas4816=6 then pvcars=175000;
else if yas4816=7 then pvcars=250001;
end;
end;
if yas4790=-1 or yas4814L=-1 or yas4814U=-1 or yas4816=-1 then pvcars=-1;
if yas4790=-2 or yas4814L=-2 or yas4814U=-2 or yas4816=-2 then pvcars=-2;
if yas4790=-3 or yas4814L=-3 or yas4814U=-3 or yas4816=-3 or yas4812=-3 then pvcars=-3;

***************** this is the end of vehicles part. **********************;


*********************************************************************;
*** If R alone or R and R's partner/spouse jointly own furniture, ***;
*** its present value - pvfurn. ***;
*********************************************************************;

pvfurn=-4;
if yas4870>-4 then FLAG_pvfurn=1;
if yas4870=1 then pvfurn=2500;
else if yas4870=2 then pvfurn=7500;
else if yas4870=3 then pvfurn=17500;
else if yas4870=4 then pvfurn=37500;
else if yas4870=5 then pvfurn=75000;
else if yas4870=6 then pvfurn=175000;
else if yas4870=7 then pvfurn=250001;
else if yas4870=-1 then pvfurn=-1;
else if yas4870=-2 then pvfurn=-2;
else if yas4870=-3 then pvfurn=-3;

************** this is the end of furniture part. *****************;


***************************************************************************;
*** If R alone or R and R's partner/spouse jointly own other assets not ***;
*** mentioned before - othsav. ********************************************;
***************************************************************************;

othsav=-4;
if yas4880 in (1,2,3) then do;
FLAG_othsav=1;
if yas4900=1 & yas4902>=0 then othsav=yas4902;
else if yas4900=2 & yas4904L>=0 & yas4904U>=0 then othsav=(yas4904L+yas4904U)/2;
if yas4900 not in (1,2) or yas4902 in (-1,-2) then do;
if 1<=yas4906<=7 then FLAG_othsav=2;
if yas4906=1 then othsav=2500;
else if yas4906=2 then othsav=7500;
else if yas4906=3 then othsav=17500;
else if yas4906=4 then othsav=37500;
else if yas4906=5 then othsav=75000;
else if yas4906=6 then othsav=175000;
else if yas4906=7 then othsav=250001;
end;
end;
if yas4880=-1 or yas4904L=-1 or yas4904U=-1 or yas4906=-1 then othsav=-1;
if yas4880=-2 or yas4904L=-2 or yas4904U=-2 or yas4906=-2 then othsav=-2;
if yas4880=-3 or yas4904L=-3 or yas4904U=-3 or yas4906=-3 or yas4902=-3 then othsav=-3;

************** this is the end of other savings. **********************;



*************************************************************************;
**** THIS IS THE END OF ASSETS. ****;
**** THE FOLLOWING IS LIABILITIES. ****;
*************************************************************************;



***********************************************************************;
*** If there is mortgage or land contract on the aforementioned land ***;
*** or property - mortgag. ***;
***********************************************************************;

mortgag=-4;
if yas3740 in (1,2) then do;
FLAG_mortgag=1;
if yas3750=1 & yas3752>=0 then mortgag=yas3752;
else if yas3750=2 & yas3754L>=0 & yas3754U>=0 then mortgag=(yas3754L+yas3754U)/2;
if yas3750 not in (1,2) or yas3752 in (-1,-2) then do;
if 1<=yas3756<=7 then FLAG_mortgag=2;
if yas3756=1 then mortgag=500;
else if yas3756=2 then mortgag=1750;
else if yas3756=3 then mortgag=3750;
else if yas3756=4 then mortgag=7500;
else if yas3756=5 then mortgag=17500;
else if yas3756=6 then mortgag=37500;
else if yas3756=7 then mortgag=50001;
end;
end;
if yas3740=-1 or yas3754L=-1 or yas3754U=-1 or yas3756=-1 then mortgag=-1;
if yas3740=-2 or yas3754L=-2 or yas3754U=-2 or yas3756=-2 then mortgag=-2;
if yas3740=-3 or yas3754L=-3 or yas3754U=-3 or yas3756=-3 or yas3752=-3 then mortgag=-3;

***************** this is the end of mortgage part. *******************;


*****************************************************************;
*** If R or R's partner/spouse has unpaid loans from Round 7 ***;
*** (yas3840=1 & yas3850=1) or still owes loans taken SDLI on ***;
*** house (yas3860=1) then total amount owed - resdebt. ***;
*****************************************************************;

resdebt=-4;
if (yas3840=1 & yas3850=1) or yas3860=1 then do;
FLAG_resdebt=1;
if yas3880=1 & yas3882>=0 then resdebt=yas3882;
else if yas3880=2 & yas3884U>=0 & yas3884L>=0 then resdebt=(yas3884L+yas3884U)/2;
if yas3880 not in (1,2) or yas3882 in (-1,-2) then do;
if 1<=yas3886<=7 then FLAG_resdebt=2;
if yas3886=1 then resdebt=500;
else if yas3886=2 then resdebt=1750;
else if yas3886=3 then resdebt=3750;
else if yas3886=4 then resdebt=7500;
else if yas3886=5 then resdebt=17500;
else if yas3886=6 then resdebt=37500;
else if yas3886=7 then resdebt=50001;
end;
end;
if yas3850=-1 or yas3860=-1 or yas3884L=-1 or yas3884U=-1 or yas3886=-1
then resdebt=-1;
if yas3850=-2 or yas3860=-2 or yas3884L=-2 or yas3884U=-2 or yas3886=-2
then resdebt=-2;
if yas3850=-3 or yas3860=-3 or yas3884L=-3 or yas3884U=-3 or yas3886=-3 or yas3882=-3
then resdebt=-3;

************** this is the end of resdebt. ****************;


***************************************************************;
*** If the respondent or his/her partner/spouse have second ***;
*** mortgages - othmort. ***;
***************************************************************;

othmort=-4;
if yas3910=1 then do;
FLAG_othmort=1;
if yas3920=1 & yas3922>=0 then othmort=yas3922;
else if yas3920=2 & yas3924U>=0 & yas3924L>=0 then othmort=(yas3924L+yas3924U)/2;
if yas3920 not in (1,2) or yas3922 in (-1,-2) then do;
if 1<=yas3926<=7 then FLAG_othmort=2;
if yas3926=1 then othmort=500;
else if yas3926=2 then othmort=1750;
else if yas3926=3 then othmort=3750;
else if yas3926=4 then othmort=7500;
else if yas3926=5 then othmort=17500;
else if yas3926=6 then othmort=37500;
else if yas3926=7 then othmort=50001;
end;
end;
if yas3910=-1 or yas3924L=-1 or yas3924U=-1 or yas3926=-1 then othmort=-1;
if yas3910=-2 or yas3924L=-2 or yas3924U=-2 or yas3926=-2 then othmort=-2;
if yas3910=-3 or yas3924L=-3 or yas3924U=-3 or yas3926=-3 or yas3922=-3 then othmort=-3;

********** this is the end of other mortgage. ******************;


*******************************************************************************;
*** If R or R's partner/spouse still owe money on these vehicles - cardebt. ***;
*******************************************************************************;

cardebt=-4;
if yas4840>-4 then FLAG_cardebt=1;
if yas4840=1 & yas4842>=0 then cardebt=yas4842;
else if yas4840=2 & yas4844L>=0 & yas4844U>=0 then cardebt=(yas4844L+yas4844U)/2;
if yas4840 not in (1,2) or yas4842 in (-1,-2) then do;
if 1<=yas4846<=7 then FLAG_cardebt=2;
if yas4846=1 then cardebt=2500;
else if yas4846=2 then cardebt=7500;
else if yas4846=3 then cardebt=17500;
else if yas4846=4 then cardebt=37500;
else if yas4846=5 then cardebt=75000;
else if yas4846=6 then cardebt=175000;
else if yas4846=7 then cardebt=250001;
end;
if yas4790=-1 or yas4844L=-1 or yas4844U=-1 or yas4846=-1 then cardebt=-1;
if yas4790=-2 or yas4844L=-2 or yas4844U=-2 or yas4846=-2 then cardebt=-2;
if yas4790=-3 or yas4844L=-3 or yas4844U=-3 or yas4846=-3 or yas4842=-3 then cardebt=-3;

**************** this is the end of car debt. **********************;

/*
*************************famedudebt**********************************;

famedudebt=-4;
if yas5011=1 then do;
flag_famedudebt=1;
if yas5011A=1 & yas5012>=0 then famedudebt=yas5012;
else if yas5011A=2 then do;
if yas5013L>=0 & yas5013U>=yas5013L then famedudebt=(yas5013L+yas5013U)/2;
else famedudebt=-3;
end;
if yas5011A not in (1,2) or yas5012 in (-1,-2) then do;
if 1<=yas5014<=7 then flag_famedudebt=2;
if yas5014=1 then famedudebt=500;
else if yas5014=2 then famedudebt=1750;
else if yas5014=3 then famedudebt=3750;
else if yas5014=4 then famedudebt=7500;
else if yas5014=5 then famedudebt=17500;
else if yas5014=6 then famedudebt=37500;
else if yas5014=7 then famedudebt=50001;
end;
end;

if yas5011=-1 or yas5011A=-1 or yas5013U=-1 or yas5013L=-1 or yas5014=-1 then famedudebt=-1;
if yas5011=-2 or yas5011A=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2 then famedudebt=-2;
if yas5011=-3 or yas5011A=-3 or yas5013U=-3 or yas5013L=-3 or yas5014=-3 or yas5012=-3 then famedudebt=-3;

*******************************************************************************************;

********************** Government loan *****************************;

govdebt=-4;
if yas5015=1 then do;
flag_govdebt=-4;
if yas5015A=1 & yas5016>=0 then govdebt=yas5016;
else if yas5015A=2 then do;
if yas5017L>=0 & yas5017U>=yas5017L then govdebt=(yas5017L+yas5017U)/2;
else govdebt=-3;
end;
if yas5015A not in (1,2) or yas5016 in (-1,-2) then do;
if 1<=yas5018<=7 then flag_govdebt=2;
if yas5018=1 then govdebt=500;
else if yas5018=2 then govdebt=1750;
else if yas5018=3 then govdebt=3750;
else if yas5018=4 then govdebt=7500;
else if yas5018=5 then govdebt=17500;
else if yas5018=6 then govdebt=37500;
else if yas5018=7 then govdebt=50001;
end;
end;

if yas5015=-1 or yas5015A=-1 or yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
if yas5015=-2 or yas5015A=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
if yas5015=-3 or yas5015A=-3 or yas5017U=-3 or yas5017L=-3 or yas5018=-3 or yas5016=-3 then govdebt=-3;


************ this is the end of govdebt. ********************************;
*/

****************************************************************************;
*** If the respondent still owes loans to family or relatives, ***;
*** means has been loaned SDLI - famdebt. ***;
****************************************************************************;

array famdebt (20) famdebt01-famdebt20;
array yas5080 (20) yas508001-yas508020;
array yas5082 (20) yas508201-yas508220;
array yas5084L (20) yas5084L01-yas5084L20;
array yas5084U (20) yas5084U01-yas5084U20;
array yas5086 (20) yas508601-yas508620;
array yas5170 (20) yas517001-yas517020;
array yas5172 (20) yas517201-yas517220;
array yas5174L (20) yas5174L01-yas5174L20;
array yas5174U (20) yas5174U01-yas5174U20;
array yas5176 (20) yas517601-yas517620;

array yas5074 (20) yas507401-yas507420;
array yas5164 (20) yas516401-yas516420;

do i=1 to dim(famdebt);
famdebt(i)=-4;
** R was NOT loaned money from family/friends at last assets interview **;
** but has been loaned SDLI. **;
if yas5040=1 then do;
FLAG_famdebt=1.1;
if yas5080(i)=1 & yas5082(i)>=0 then famdebt(i)=yas5082(i);
else if yas5080(i)=2 & yas5084L(i)>=0 & yas5084U(i)>=0
then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
if yas5080(i) not in (1,2) or yas5082(i) in (-1,-2) then do;
if 1<=yas5086(i)<=7 then FLAG_famdebt=2.1;
if yas5086(i)=1 then famdebt(i)=500;
else if yas5086(i)=2 then famdebt(i)=1750;
else if yas5086(i)=3 then famdebt(i)=3750;
else if yas5086(i)=4 then famdebt(i)=7500;
else if yas5086(i)=5 then famdebt(i)=17500;
else if yas5086(i)=6 then famdebt(i)=37500;
else if yas5086(i)=7 then famdebt(i)=50001;
end;
end;
if yas5040=-1 or yas5074(i)=-1 or yas5086(i)=-1 or yas5084L(i)=-1 or yas5084U(i)=-1
then famdebt(i)=-1;
if yas5040=-2 or yas5074(i)=-2 or yas5086(i)=-2 or yas5084L(i)=-2 or yas5084U(i)=-2
then famdebt(i)=-2;
if yas5040=-3 or yas5074(i)=-3 or yas5086(i)=-3 or yas5084L(i)=-3 or yas5084U(i)=-3 or yas5082(i)=-3
then famdebt(i)=-3;

** R was loaned money from family/friends at last assets interview **;
** and has also been loaned SDLI. **;
if yas5130=1 then do;
FLAG_famdebt=1.2;
if yas5170(i)=1 & yas5172(i)>=0 then famdebt(i)=yas5172(i);
else if yas5170(i)=2 & yas5174L(i)>=0 & yas5174U(i)>-0
then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
if yas5170(i) not in (1,2) or yas5172(i) in (-1,-2) then do;
if 1<=yas5176(i)<=7 then FLAG_famdebt=2.2;
if yas5176(i)=1 then famdebt(i)=500;
else if yas5176(i)=2 then famdebt(i)=1750;
else if yas5176(i)=3 then famdebt(i)=3750;
else if yas5176(i)=4 then famdebt(i)=7500;
else if yas5176(i)=5 then famdebt(i)=17500;
else if yas5176(i)=6 then famdebt(i)=37500;
else if yas5176(i)=7 then famdebt(i)=50001;
end;
end;
if yas5130=-1 or yas5164(i)=-1 or yas5176(i)=-1 or yas5174L(i)=-1 or yas5174U(i)=-1
then famdebt(i)=-1;
if yas5130=-2 or yas5164(i)=-2 or yas5176(i)=-2 or yas5174L(i)=-2 or yas5174U(i)=-2
then famdebt(i)=-2;
if yas5130=-3 or yas5164(i)=-3 or yas5176(i)=-3 or yas5174L(i)=-3 or yas5174U(i)=-3 or yas5172(i)=-3
then famdebt(i)=-3;
end;

***************** this is the end of family debts. ************************;



******* Checks for cases when R does not know who lent R the money. *******;
/*
who=0;
if yas5060=1|yas5062=1 then who=1;
if yas5150=1|yas5152=1 then who=2;
*/


****************************************************************;
*** If R or R's partner/spouse jointly have other debts from ***;
*** loans, credit cards, etc. ***;
****************************************************************;

othdebt=-4;
if yas5210=1 then do;
FLAG_othdebt=1;
if yas5220=1 & yas5222>=0 then othdebt=yas5222;
else if yas5220=2 & yas5224L>=0 & yas5224U>=0 then othdebt=(yas5224L+yas5224U)/2;
if yas5220 not in (1,2) or yas5222 in (-1,-2) then do;
if 1<=yas5226<=7 then FLAG_othdebt=2;
if yas5226=1 then othdebt=500;
else if yas5226=2 then othdebt=1750;
else if yas5226=3 then othdebt=3750;
else if yas5226=4 then othdebt=7500;
else if yas5226=5 then othdebt=17500;
else if yas5226=6 then othdebt=37500;
else if yas5226=7 then othdebt=50001;
end;
end;
if yas5210=-1 or yas5224L=-1 or yas5224U=-1 or yas5226=-1 then othdebt=-1;
if yas5210=-2 or yas5224L=-2 or yas5224U=-2 or yas5226=-2 then othdebt=-2;
if yas5210=-3 or yas5224L=-3 or yas5224U=-3 or yas5226=-3 or yas5222=-3 then othdebt=-3;

***************** this is the end of other debts. **************************;

****************************************************************************;
**** THIS IS THE END OF LIABILITIES. ****;
****************************************************************************;




******************************************************************;
***** THIS IS THE END OF DATA CLEANING. *****;
***** THE FOLLOWING IS CALCULATION. *****;
******************************************************************;


************************************************************************;
*** Compute the respondent's household net worth (hhworthY). ***;
*** hhworthY=assets-liabilities. YAST-105 is the question ***;
*** determining whether respondents are asked the assets question. ***;
************************************************************************;

array varsasst (*) pvranch pvmbst pvmb pvst pvapt pvbuss othreal /*items of assets */
retdsav banksav bonds stocks pvcars pvfurn othsav;
array varsliab (*) mortgag resdebt othmort cardebt othdebt
famdebt01-famdebt20; /*items of liabilities */

array flgsasst (*) flag_pvranch flag_pvmbst flag_pvmb flag_pvst flag_pvapt
flag_pvbuss flag_othreal flag_retdsav flag_banksav flag_bonds
flag_stocks flag_pvcars flag_pvfurn flag_othsav;
array flgsliab (*) flag_mortgag flag_resdebt flag_othmort flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

array ahousedebt (*) mortgag resdebt othmort;
array afinance (*) retdsav banksav bonds stocks othsav;
array anonfinance (*) othreal pvcars pvfurn pvbuss;
array adebt (*) cardebt othdebt famdebt01-famdebt20;


array flgshsdt(*) flag_mortgag flag_resdebt flag_othmort;

array flgsfin(*) flag_retdsav flag_banksav flag_bonds flag_stocks flags_othsav;

array flgsnonfin(*) flag_othreal flag_pvcars flag_pvfurn flag_pvbuss;

array flgsdebt(*) flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

if yas1400=-4 then do;
hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;
end;

if (yas1400=0 or yas1400=1) then do;

hhworthY=0; assets=0; liabilities=0; housedebt=0;finance=0;nonfinance=0;debt=0;

do i=1 to dim(varsasst);
if varsasst(i) not in(-1,-2,-3,-4) then assets=assets+varsasst(i);
if varsasst(i) in (-1,-2,-3) then flgsasst(i)=-3;
end;

do i=1 to dim(varsliab);
if varsliab(i)>=0 then liabilities=liabilities+varsliab(i);
if varsliab(i) in (-1,-2,-3) then flgsliab(i)=-3;
end;

hhworthY=assets-liabilities;

do i=1 to dim(ahousedebt);
if ahousedebt(i)>=0 then housedebt=housedebt+ahousedebt(i);
if ahousedebt(i) in (-1,-2,-3) then flgshsdt(i)=-3;
end;
do i=1 to dim(afinance);
if afinance(i)>=0 then finance=finance+afinance(i);
if afinance(i) in (-1, -2, -3) then flgsfin(i)=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i) not in(-1,-2,-3,-4) then nonfinance=nonfinance+anonfinance(i);
if anonfinance(i) in (-1, -2, -3) then flgsnonfin(i)=-3;
end;
do i=1 to dim(adebt);
if adebt(i)>=0 then debt=debt+adebt(i);
if adebt(i) in (-1, -2, -3) then flgsdebt(i)=-3;
end;

end;




*** Code hhworthY as a valid skip for those who were not asked the assets questions;
if yas1400=-4 then do;
hhworthY=-4;
vskpHHY=1;
end;

*** Code hhworthY as an invalid skip for those who did not give valid responses;
do i=1 to dim(varsasst);
if varsasst(i)=-1 then do;
hhworthY=-1;
assets=-1;
invskpHHY=1;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-1 then do;
hhworthY=-1;
invskpHHY=1;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-2 then do;
hhworthY=-2;
assets=-2;
invskpHHY=2;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-2 then do;
hhworthY=-2;
invskpHHY=2;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-3 then do;
hhworthY=-3;
assets=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-3 then do;
hhworthY=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(ahousedebt);
if ahousedebt(i)=-1 then housedebt=-1;
else if ahousedebt(i)=-2 then housedebt=-2;
else if ahousedebt(i)=-3 then housedebt=-3;
end;
do i=1 to dim(afinance);
if afinance(i)=-1 then finance=-1;
else if afinance(i)=-2 then finance=-2;
else if afinance(i)=-3 then finance=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)=-1 then nonfinance=-1;
else if anonfinance(i)=-2 then nonfinance=-2;
else if anonfinance(i)=-3 then nonfinance=-3;
end;
do i=1 to dim(adebt);
if adebt(i)=-1 then debt=-1;
else if adebt(i)=-2 then debt=-2;
else if adebt(i)=-3 then debt=-3;
end;

hhworthY=round(hhworthY,1);
assets=round(assets,1);
housedebt=round(housedebt,1);
house_value=round(house_value,1);
finance=round(finance,1);
nonfinance=round(nonfinance,1);
debt=round(debt,1);


************* Change all the -1s, -2s to -3s. ***************;

array finalv(*) hhworthY assets housedebt house_value finance nonfinance debt;
do i=1 to dim(finalv);
if finalv(i) in (-1,-2) then finalv(i)=-3;
end;

run;

Return to top


Round 6

******************* Start of the Youth Asset Section (hhworthY) ***********************;
* *;
* First create the following components of the hhworthY such as real estate, loans, *;
* cars etc.Each subsection computes one item of the total asset of Youth Respondent *;
* and his/her spouse or partner. Flag variables are created to indicate whether *;
* R/family received that asset item (FLAG_item in (1,2,-3)) and if so was the amount *;
* computed directly from the amount reported by R (FLAG_item=1) or it was computed *;
* from estimates given by R (FLAG_item=2) or it could not be computed (FLAG_item=-3). *;
***************************************************************************************;

libname r6 "C:\My Documents\NLSY97\Round8\Data\r6";
data r6.age20r6;
set r6.r6_20;
round=6;




housing_type=-4;
house_value=-4;


**********************************************************************;
*** If the respondent owns some land, its present value - pvranch. ***;
**********************************************************************;

pvranch=-4;
*** If R alone or R and R's partner/spouse jointly own all of it. ***;
if yas1400=1 & (yas1610=1 or yas1610=2) then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas1860=1 & yas1862>=0 then pvranch=yas1862; /*how about lt 0?*/
else if yas1860=2 & yas1864L>=0 & yas1864U>=0 then do;
if yas1864U>=yas1864L then pvranch=(yas1864L+yas1864U)/2;
else pvranch=-3;
end;
if yas1860 not in (1,2) or yas1862 in (-1,-2) then do;
if 1<=yas1866<=7 then FLAG_pvranch=2;
if yas1866=1 then pvranch=12500;
else if yas1866=2 then pvranch=37500;
else if yas1866=3 then pvranch=75000;
else if yas1866=4 then pvranch=175000;
else if yas1866=5 then pvranch=375000;
else if yas1866=6 then pvranch=750000;
else if yas1866=7 then pvranch=1000001;
end;
end;


*** If R alone or R and R's partner/spouse jointly own part of it (100%). ***;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2140=1 & yas2142>=0 then pvranch=yas2142;
else if yas2140=2 & yas2144L>=0 & yas2144U>=0 then do;
if yas2144U>=yas2144L then pvranch=(yas2144L+yas2144U)/2;
else pvranch=-3;
end;
if yas2140 not in (1,2) or yas2142 in (-1,-2) then do;
if 1<=yas2146<=7 then FLAG_pvranch=2;
if yas2146=1 then pvranch=12500;
else if yas2146=2 then pvranch=37500;
else if yas2146=3 then pvranch=75000;
else if yas2146=4 then pvranch=175000;
else if yas2146=5 then pvranch=375000;
else if yas2146=6 then pvranch=750000;
else if yas2146=7 then pvranch=1000001;
end;
end;


** If R alone or R and R's partner/spouse jointly own part of it (< 100%) **;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120~=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2170=1 & yas2172>=0 then pvranch=yas2172;
else if yas2170=2 & yas2174L>=0 & yas2174U>=0 then do;
if yas2174U>=yas2174L then pvranch=(yas2174L+yas2174U)/2;
else pvranch=-3;
end;
if yas2170 not in (1,2) or yas2172 in (-1,-2) then do;
if 1<=yas2176<=7 then FLAG_pvranch=2;
if yas2176=1 then pvranch=12500;
else if yas2176=2 then pvranch=37500;
else if yas2176=3 then pvranch=75000;
else if yas2176=4 then pvranch=175000;
else if yas2176=5 then pvranch=375000;
else if yas2176=6 then pvranch=750000;
else if yas2176=7 then pvranch=1000001;
end;
end;

if yas1400=-1 or yas1610=-1
or yas1864L=-1 or yas1864U=-1 or yas1866=-1
or yas2144L=-1 or yas2144U=-1 or yas2146=-1
or yas2174L=-1 or yas2174U=-1 or yas2176=-1 then pvranch=-1;

if yas1400=-2 or yas1610=-2
or yas1864L=-2 or yas1864U=-2 or yas1866=-2
or yas2144L=-2 or yas2144U=-2 or yas2146=-2
or yas2174L=-2 or yas2174U=-2 or yas2176=-2 then pvranch=-2;

if yas1400=-3 or yas1610=-3
or yas1864L=-3 or yas1864U=-3 or yas1866=-3
or yas2144L=-3 or yas2144U=-3 or yas2146=-3
or yas2174L=-3 or yas2174U=-3 or yas2176=-3
or yas1862=-3 or yas2142=-3 or yas2172=-3 then pvranch=-3;

if flag_pvranch=1 then do;
housing_type=2;
house_value=pvranch;
end;

if yas1610=6 then do;
housing_type=6;
house_value=-4;
end;

********* this is the end of land part. ***************;


************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home ***;
*** and its site, its present value - pvmbst. ***;
************************************************************************;

pvmbst=-4;
if yas2520 in (1,2) then do;
FLAG_pvmbst=1;
flagck_mbst=1;
if yas2550=1 & yas2552>=0 then pvmbst=yas2552;
else if yas2550=2 & yas2554L>=0 & yas2554U>=0 then do;
if yas2554U>=yas2554L then pvmbst=(yas2554L+yas2554U)/2;
else pvmbst=-3;
end;
if yas2550 not in (1,2) or yas2552 in (-1,-2) then do;
if 1<=yas2556<=7 then FLAG_pvmbst=2;
if yas2556=1 then pvmbst=500;
else if yas2556=2 then pvmbst=1750;
else if yas2556=3 then pvmbst=3750;
else if yas2556=4 then pvmbst=7500;
else if yas2556=5 then pvmbst=17500;
else if yas2556=6 then pvmbst=37500;
else if yas2556=7 then pvmbst=50001;
end;
end;
if yas2520=-1 or yas2554L=-1 or yas2554U=-1 or yas2556=-1 then pvmbst=-1;
if yas2520=-2 or yas2554L=-2 or yas2554U=-2 or yas2556=-2 then pvmbst=-2;
if yas2520=-3 or yas2554L=-3 or yas2554U=-3 or yas2556=-3 or yas2552=-3 then pvmbst=-3;

if flag_pvmbst=1 then do;
housing_type=4;
house_value=pvmbst;
end;

***** this is the end of mobile home & site. *****;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home, ***;
*** its present value - pvmb. ***;
*************************************************************************;

pvmb=-4;
if yas2520 in (3,4) then do;
FLAG_pvmb=1;
flagck_mb=1;
if yas2760=1 & yas2762>=0 then pvmb=yas2762;
else if yas2760=2 & yas2764L>=0 & yas2764U>=0 then do;
if yas2764U>=yas2764L then pvmb=(yas2764L+yas2764U)/2;
else pvmb=-3;
end;
if yas2760 not in (1,2) or yas2762 in (-1,-2) then do;
if 1<=yas2766<=7 then FLAG_pvmb=2;
if yas2766=1 then pvmb=12500;
else if yas2766=2 then pvmb=37500;
else if yas2766=3 then pvmb=75000;
else if yas2766=4 then pvmb=175000;
else if yas2766=5 then pvmb=375000;
else if yas2766=6 then pvmb=750000;
else if yas2766=7 then pvmb=1000001;
end;
end;
if yas2520=-1 or yas2764L=-1 or yas2764U=-1 or yas2766=-1 then pvmb=-1;
if yas2520=-2 or yas2764L=-2 or yas2764U=-2 or yas2766=-2 then pvmb=-2;
if yas2520=-3 or yas2764L=-3 or yas2764U=-3 or yas2766=-3 or yas2762=-3 then pvmb=-3;

if flag_pvmb=1 then do;
housing_type=3;
house_value=pvmb;
end;

******* this is the end of mobile home. ********;


******************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home site, ***;
*** its present value - pvst. ***;
******************************************************************************;

pvst=-4;
if yas2520 in (5,6) then do;
FLAG_pvst=1;
flagck_st=1;
if yas3010=1 & yas3012>=0 then pvst=yas3012;
else if yas3010=2 & yas3014L>=0 & yas3014U>=0 then do;
if yas3014U>=yas3014L then pvst=(yas3014L+yas3014U)/2;
else pvst=-3;
end;
if yas3010 not in (1,2) or yas3012 in (-1,-2) then do;
if 1<=yas3016<=7 then FLAG_pvst=2;
if yas3016=1 then pvst=12500;
else if yas3016=2 then pvst=57500;
else if yas3016=3 then pvst=75000;
else if yas3016=4 then pvst=175000;
else if yas3016=5 then pvst=575000;
else if yas3016=6 then pvst=750000;
else if yas3016=7 then pvst=1000001;
end;
end;
if yas2520=-1 or yas3014L=-1 or yas3014U=-1 or yas3016=-1 then pvst=-1;
if yas2520=-2 or yas3014L=-2 or yas3014U=-2 or yas3016=-2 then pvst=-2;
if yas2520=-3 or yas3014L=-3 or yas3014U=-3 or yas3016=-3 or yas3012=-3 then pvst=-3;

if flag_pvst=1 then do;
housing_type=5;
house_value=pvst;
end;

if yas2520=8 then do;
housing_type=6;
house_value=-4;
end;
******** this is the end of mobile home site. ********;

*******************************************************;
*** THIS IS THE END OF MOBILE HOME & ITS SITE PART. ***;
*******************************************************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own an apartment, ***;
*** its present value - pvapt. ***;
*************************************************************************;

pvapt=-4;
if yas3310 in (1,2) then do;
FLAG_pvapt=1;
flagck_apt=1;
if yas3380=1 & yas3382>=0 then pvapt=yas3382;
else if yas3380=2 & yas3384L>=0 & yas3384U>=0 then do;
if yas3384U>=yas3384L then pvapt=(yas3384L+yas3384U)/2;
else pvapt=-3;
end;
if yas3380 not in (1,2) or yas3382 in (-1,-2) then do;
if 1<=yas3386<=7 then FLAG_pvapt=2;
if yas3386=1 then pvapt=500;
else if yas3386=2 then pvapt=1750;
else if yas3386=3 then pvapt=3750;
else if yas3386=4 then pvapt=7500;
else if yas3386=5 then pvapt=17500;
else if yas3386=6 then pvapt=37500;
else if yas3386=7 then pvapt=50001;
end;
end;
if yas3310=-1 or yas3384L=-1 or yas3384U=-1 or yas3386=-1 then pvapt=-1;
if yas3310=-2 or yas3384L=-2 or yas3384U=-2 or yas3386=-2 then pvapt=-2;
if yas3310=-3 or yas3384L=-3 or yas3384U=-3 or yas3386=-3 or yas3382=-3 then pvapt=-3;

if yas3310 in (1,2) and yas3340=0 then housing_type=1;
else if yas3310 in (1,2) and yas3340=1 and yas3360=1 then housing_type=8;
else if yas3310 in (1,2) and yas3340=1 and yas3360=2 then housing_type=7;

if flag_pvapt=1 then house_value=pvapt;

if yas3310=4 then do;
housing_type=6;
house_value=-4;
end;

/*************************************************************/

/*************************************************************/

********** this is the end of apartment part. *********************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a business, ***;
*** partnership or professional practice, its present value - pvbuss. ***;
*************************************************************************;

pvbuss=-4;
if yas4010 in (1,2) then do;
FLAG_pvbuss=1;
if yas4030=1 & yas4032>=0 then pvbuss=yas4032;
else if yas4030=2 then pvbuss=(yas4034L+yas4034U)/2;
if yas4030 not in (1,2) or yas4032 in (-1,-2) then do;
if 1<=yas4036<=7 then FLAG_pvbuss=2;
if yas4036=1 then pvbuss=12500;
else if yas4036=2 then pvbuss=37500;
else if yas4036=3 then pvbuss=75000;
else if yas4036=4 then pvbuss=175000;
else if yas4036=5 then pvbuss=375000;
else if yas4036=6 then pvbuss=750000;
else if yas4036=7 then pvbuss=1000001;
end;
end;
if yas4010=-1 or yas4034L=-1 or yas4034U=-1 or yas4036=-1 then pvbuss=-1;
if yas4010=-2 or yas4034L=-2 or yas4034U=-2 or yas4036=-2 then pvbuss=-2;
if yas4010=-3 or yas4034L=-3 or yas4034U=-3 or yas4036=-3 or yas4032=-3 then pvbuss=-3;

********* this is the end of business part. *****************;


*******************************************************************;
*** If R alone or R and R's partner/spouse jointly own a second ***;
*** real estate, its present value - othreal. ***;
*******************************************************************;

othreal=-4;
if yas4140 in (1,2) then do;
FLAG_othreal=1;
if yas4160=1 & yas4162>=0 then othreal=yas4162;
else if yas4160=2 then othreal=(yas4164L+yas4164U)/2;
if yas4160 not in (1,2) or yas4162 in (-1,-2) then do;
if 1<=yas4166<=7 then FLAG_othreal=2;
if yas4166=1 then othreal=12500;
else if yas4166=2 then othreal=37500;
else if yas4166=3 then othreal=75000;
else if yas4166=4 then othreal=175000;
else if yas4166=5 then othreal=375000;
else if yas4166=6 then othreal=750000;
else if yas4166=7 then othreal=1000001;
end;
end;
if yas4140=-1 or yas4164L=-1 or yas4164U=-1 or yas4166=-1 then othreal=-1;
if yas4140=-2 or yas4164L=-2 or yas4164U=-2 or yas4166=-2 then othreal=-2;
if yas4140=-3 or yas4164L=-3 or yas4164U=-3 or yas4166=-3 or yas4162=-3 then othreal=-3;

**************** this is the end of other real estate. ********************;


******************************************************************************;
*** If R or R's partner/spouse have retirement plans or pensions - retdsav ***;
******************************************************************************;

retdsav=-4;
if yas4270 in (1,2,3) then do;
FLAG_retdsav=1;
if yas4290=1 & yas4292>=0 then retdsav=yas4292;
else if yas4290=2 & yas4294U>=0 & yas4294L>=0 then retdsav=(yas4294L+yas4294U)/2;
if yas4290 not in (1,2) or yas4292 in (-1,-2) then do;
if 1<=yas4296<=7 then FLAG_retdsav=2;
if yas4296=1 then retdsav=2500;
else if yas4296=2 then retdsav=7500;
else if yas4296=3 then retdsav=17500;
else if yas4296=4 then retdsav=37500;
else if yas4296=5 then retdsav=75000;
else if yas4296=6 then retdsav=175000;
else if yas4296=7 then retdsav=250001;
end;
end;
if yas4270=-1 or yas4294L=-1 or yas4294U=-1 or yas4296=-1 then retdsav=-1;
if yas4270=-2 or yas4294L=-2 or yas4294U=-2 or yas4296=-2 then retdsav=-2;
if yas4270=-3 or yas4294L=-3 or yas4294U=-3 or yas4296=-3 or yas4292=-3 then retdsav=-3;

******** this is the end of retirement plans. ****************;


*******************************************************************;
*** If R or R's partner/spouse have banksav in saving accounts, ***;
*** money market, funds,trusts, - banksav. ***;
*******************************************************************;

banksav=-4;
if yas4400 in (1,2,3) then do;
FLAG_banksav=1;
if yas4420=1 & yas4422>=0 then banksav=yas4422;
else if yas4420=2 & yas4424U>=0 & yas4424L>=0 then do;
if yas4424U>=yas4424L then banksav=(yas4424L+yas4424U)/2;
else banksav=-3;
end;
if yas4420 not in (1,2) or yas4422 in (-1,-2) then do;
if 1<=yas4426<=7 then FLAG_banksav=2;
if yas4426=1 then banksav=500;
else if yas4426=2 then banksav=1750;
else if yas4426=3 then banksav=3750;
else if yas4426=4 then banksav=7500;
else if yas4426=5 then banksav=17500;
else if yas4426=6 then banksav=37500;
else if yas4426=7 then banksav=50001;
end;
end;
if yas4400=-1 or yas4424L=-1 or yas4424U=-2 or yas4426=-1 then banksav=-1;
if yas4400=-2 or yas4424L=-2 or yas4424U=-2 or yas4426=-2 then banksav=-2;
if yas4400=-3 or yas4424L=-3 or yas4424U=-3 or yas4426=-3 or yas4422=-3 then banksav=-3;

************* this is the end of bank savings. ****************;


******************************************************************************;
*** If R or R's partner/spouse have other banksav in bonds or cds - bonds. ***;
******************************************************************************;

bonds=-4;
if yas4530 in (1,2,3) then do;
FLAG_bonds=1;
if yas4550=1 & yas4552>=0 then bonds=yas4552;
else if yas4550=2 & yas4554U>=0 & yas4554L>=0 then bonds=(yas4554L+yas4554U)/2;
if yas4550 not in (1,2) or yas4552 in (-1,-2) then do;
if 1<=yas4556<=7 then FLAG_bonds=2;
if yas4556=1 then bonds=500;
else if yas4556=2 then bonds=1750;
else if yas4556=3 then bonds=3750;
else if yas4556=4 then bonds=7500;
else if yas4556=5 then bonds=17500;
else if yas4556=6 then bonds=37500;
else if yas4556=7 then bonds=50001;
end;
end;
if yas4530=-1 or yas4554L=-1 or yas4554U=-1 or yas4556=-1 then bonds=-1;
if yas4530=-2 or yas4554L=-2 or yas4554U=-2 or yas4556=-2 then bonds=-2;
if yas4530=-3 or yas4554L=-3 or yas4554U=-3 or yas4556=-3 or yas4552=-3 then bonds=-3;

***************** this is the end of bonds. **********************;


*** If the respondent or his/her partner/spouse have stocks, mutual funds - stocks;

stocks=-4;
if yas4660 in (1,2,3) then do;
FLAG_stocks=1;
if yas4680=1 & yas4682>=0 then stocks=yas4682;
else if yas4680=2 & yas4684L>=0 & yas4684U>=0 then stocks=(yas4684L+yas4684U)/2;
if yas4680 not in (1,2) or yas4682 in (-1,-2) then do;
if 1<=yas4686<=7 then FLAG_stocks=2;
if yas4686=1 then stocks=500;
else if yas4686=2 then stocks=1750;
else if yas4686=3 then stocks=3750;
else if yas4686=4 then stocks=7500;
else if yas4686=5 then stocks=17500;
else if yas4686=6 then stocks=37500;
else if yas4686=7 then stocks=50001;
end;
end;
if yas4660=-1 or yas4684L=-1 or yas4684U=-1 or yas4686=-1 then stocks=-1;
if yas4660=-2 or yas4684L=-2 or yas4684U=-2 or yas4686=-2 then stocks=-2;
if yas4660=-3 or yas4684L=-3 or yas4684U=-3 or yas4686=-3 or yas4682=-3 then stocks=-3;

****************** this is the end of stocks. ***********************;


************************************************************************;
*** If the respondent alone or respondent and his/her partner/spouse ***;
*** jointly own vehicles, their present value - pvcars. ***;
************************************************************************;

pvcars=-4;
if yas4790 in (1,2,3) then do;
FLAG_pvcars=1;
if yas4810=1 & yas4812>=0 then pvcars=yas4812;
else if yas4810=2 & yas4814L>=0 & yas4814U>=0 then do;
if yas4814U>=yas4814L then pvcars=(yas4814L+yas4814U)/2;
else pvcars=-3;
end;
if yas4810 not in (1,2) or yas4812 in (-1,-2) then do;
if 1<=yas4816<=7 then FLAG_pvcars=2;
if yas4816=1 then pvcars=2500;
else if yas4816=2 then pvcars=7500;
else if yas4816=3 then pvcars=17500;
else if yas4816=4 then pvcars=37500;
else if yas4816=5 then pvcars=75000;
else if yas4816=6 then pvcars=175000;
else if yas4816=7 then pvcars=250001;
end;
end;
if yas4790=-1 or yas4814L=-1 or yas4814U=-1 or yas4816=-1 then pvcars=-1;
if yas4790=-2 or yas4814L=-2 or yas4814U=-2 or yas4816=-2 then pvcars=-2;
if yas4790=-3 or yas4814L=-3 or yas4814U=-3 or yas4816=-3 or yas4812=-3 then pvcars=-3;

***************** this is the end of vehicles part. **********************;


*********************************************************************;
*** If R alone or R and R's partner/spouse jointly own furniture, ***;
*** its present value - pvfurn. ***;
*********************************************************************;

pvfurn=-4;
if yas4870>-4 then FLAG_pvfurn=1;
if yas4870=1 then pvfurn=2500;
else if yas4870=2 then pvfurn=7500;
else if yas4870=3 then pvfurn=17500;
else if yas4870=4 then pvfurn=37500;
else if yas4870=5 then pvfurn=75000;
else if yas4870=6 then pvfurn=175000;
else if yas4870=7 then pvfurn=250001;
else if yas4870=-1 then pvfurn=-1;
else if yas4870=-2 then pvfurn=-2;
else if yas4870=-3 then pvfurn=-3;

************** this is the end of furniture part. *****************;


***************************************************************************;
*** If R alone or R and R's partner/spouse jointly own other assets not ***;
*** mentioned before - othsav. ********************************************;
***************************************************************************;

othsav=-4;
if yas4880 in (1,2,3) then do;
FLAG_othsav=1;
if yas4900=1 & yas4902>=0 then othsav=yas4902;
else if yas4900=2 & yas4904L>=0 & yas4904U>=0 then othsav=(yas4904L+yas4904U)/2;
if yas4900 not in (1,2) or yas4902 in (-1,-2) then do;
if 1<=yas4906<=7 then FLAG_othsav=2;
if yas4906=1 then othsav=2500;
else if yas4906=2 then othsav=7500;
else if yas4906=3 then othsav=17500;
else if yas4906=4 then othsav=37500;
else if yas4906=5 then othsav=75000;
else if yas4906=6 then othsav=175000;
else if yas4906=7 then othsav=250001;
end;
end;
if yas4880=-1 or yas4904L=-1 or yas4904U=-1 or yas4906=-1 then othsav=-1;
if yas4880=-2 or yas4904L=-2 or yas4904U=-2 or yas4906=-2 then othsav=-2;
if yas4880=-3 or yas4904L=-3 or yas4904U=-3 or yas4906=-3 or yas4902=-3 then othsav=-3;

************** this is the end of other savings. **********************;



*************************************************************************;
**** THIS IS THE END OF ASSETS. ****;
**** THE FOLLOWING IS LIABILITIES. ****;
*************************************************************************;



***********************************************************************;
*** If there is mortgage or land contract on the aforementioned land ***;
*** or property - mortgag. ***;
***********************************************************************;

mortgag=-4;
if yas3740 in (1,2) then do;
FLAG_mortgag=1;
if yas3750=1 & yas3752>=0 then mortgag=yas3752;
else if yas3750=2 & yas3754L>=0 & yas3754U>=0 then mortgag=(yas3754L+yas3754U)/2;
if yas3750 not in (1,2) or yas3752 in (-1,-2) then do;
if 1<=yas3756<=7 then FLAG_mortgag=2;
if yas3756=1 then mortgag=500;
else if yas3756=2 then mortgag=1750;
else if yas3756=3 then mortgag=3750;
else if yas3756=4 then mortgag=7500;
else if yas3756=5 then mortgag=17500;
else if yas3756=6 then mortgag=37500;
else if yas3756=7 then mortgag=50001;
end;
end;
if yas3740=-1 or yas3754L=-1 or yas3754U=-1 or yas3756=-1 then mortgag=-1;
if yas3740=-2 or yas3754L=-2 or yas3754U=-2 or yas3756=-2 then mortgag=-2;
if yas3740=-3 or yas3754L=-3 or yas3754U=-3 or yas3756=-3 or yas3752=-3 then mortgag=-3;

***************** this is the end of mortgage part. *******************;


*****************************************************************;
*** If R or R's partner/spouse has unpaid loans from Round 7 ***;
*** (yas3840=1 & yas3850=1) or still owes loans taken SDLI on ***;
*** house (yas3860=1) then total amount owed - resdebt. ***;
*****************************************************************;

resdebt=-4;
if (yas3840=1 & yas3850=1) or yas3860=1 then do;
FLAG_resdebt=1;
if yas3880=1 & yas3882>=0 then resdebt=yas3882;
else if yas3880=2 & yas3884U>=0 & yas3884L>=0 then resdebt=(yas3884L+yas3884U)/2;
if yas3880 not in (1,2) or yas3882 in (-1,-2) then do;
if 1<=yas3886<=7 then FLAG_resdebt=2;
if yas3886=1 then resdebt=500;
else if yas3886=2 then resdebt=1750;
else if yas3886=3 then resdebt=3750;
else if yas3886=4 then resdebt=7500;
else if yas3886=5 then resdebt=17500;
else if yas3886=6 then resdebt=37500;
else if yas3886=7 then resdebt=50001;
end;
end;
if yas3850=-1 or yas3860=-1 or yas3884L=-1 or yas3884U=-1 or yas3886=-1
then resdebt=-1;
if yas3850=-2 or yas3860=-2 or yas3884L=-2 or yas3884U=-2 or yas3886=-2
then resdebt=-2;
if yas3850=-3 or yas3860=-3 or yas3884L=-3 or yas3884U=-3 or yas3886=-3 or yas3882=-3
then resdebt=-3;

************** this is the end of resdebt. ****************;


***************************************************************;
*** If the respondent or his/her partner/spouse have second ***;
*** mortgages - othmort. ***;
***************************************************************;

othmort=-4;
if yas3910=1 then do;
FLAG_othmort=1;
if yas3920=1 & yas3922>=0 then othmort=yas3922;
else if yas3920=2 & yas3924U>=0 & yas3924L>=0 then othmort=(yas3924L+yas3924U)/2;
if yas3920 not in (1,2) or yas3922 in (-1,-2) then do;
if 1<=yas3926<=7 then FLAG_othmort=2;
if yas3926=1 then othmort=500;
else if yas3926=2 then othmort=1750;
else if yas3926=3 then othmort=3750;
else if yas3926=4 then othmort=7500;
else if yas3926=5 then othmort=17500;
else if yas3926=6 then othmort=37500;
else if yas3926=7 then othmort=50001;
end;
end;
if yas3910=-1 or yas3924L=-1 or yas3924U=-1 or yas3926=-1 then othmort=-1;
if yas3910=-2 or yas3924L=-2 or yas3924U=-2 or yas3926=-2 then othmort=-2;
if yas3910=-3 or yas3924L=-3 or yas3924U=-3 or yas3926=-3 or yas3922=-3 then othmort=-3;

********** this is the end of other mortgage. ******************;


*******************************************************************************;
*** If R or R's partner/spouse still owe money on these vehicles - cardebt. ***;
*******************************************************************************;

cardebt=-4;
if yas4840>-4 then FLAG_cardebt=1;
if yas4840=1 & yas4842>=0 then cardebt=yas4842;
else if yas4840=2 & yas4844L>=0 & yas4844U>=0 then cardebt=(yas4844L+yas4844U)/2;
if yas4840 not in (1,2) or yas4842 in (-1,-2) then do;
if 1<=yas4846<=7 then FLAG_cardebt=2;
if yas4846=1 then cardebt=2500;
else if yas4846=2 then cardebt=7500;
else if yas4846=3 then cardebt=17500;
else if yas4846=4 then cardebt=37500;
else if yas4846=5 then cardebt=75000;
else if yas4846=6 then cardebt=175000;
else if yas4846=7 then cardebt=250001;
end;
if yas4790=-1 or yas4844L=-1 or yas4844U=-1 or yas4846=-1 then cardebt=-1;
if yas4790=-2 or yas4844L=-2 or yas4844U=-2 or yas4846=-2 then cardebt=-2;
if yas4790=-3 or yas4844L=-3 or yas4844U=-3 or yas4846=-3 or yas4842=-3 then cardebt=-3;

**************** this is the end of car debt. **********************;

/*
*************************famedudebt**********************************;

famedudebt=-4;
if yas5011=1 then do;
flag_famedudebt=1;
if yas5011A=1 & yas5012>=0 then famedudebt=yas5012;
else if yas5011A=2 then do;
if yas5013L>=0 & yas5013U>=yas5013L then famedudebt=(yas5013L+yas5013U)/2;
else famedudebt=-3;
end;
if yas5011A not in (1,2) or yas5012 in (-1,-2) then do;
if 1<=yas5014<=7 then flag_famedudebt=2;
if yas5014=1 then famedudebt=500;
else if yas5014=2 then famedudebt=1750;
else if yas5014=3 then famedudebt=3750;
else if yas5014=4 then famedudebt=7500;
else if yas5014=5 then famedudebt=17500;
else if yas5014=6 then famedudebt=37500;
else if yas5014=7 then famedudebt=50001;
end;
end;

if yas5011=-1 or yas5011A=-1 or yas5013U=-1 or yas5013L=-1 or yas5014=-1 then famedudebt=-1;
if yas5011=-2 or yas5011A=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2 then famedudebt=-2;
if yas5011=-3 or yas5011A=-3 or yas5013U=-3 or yas5013L=-3 or yas5014=-3 or yas5012=-3 then famedudebt=-3;

*******************************************************************************************;

********************** Government loan *****************************;

govdebt=-4;
if yas5015=1 then do;
flag_govdebt=-4;
if yas5015A=1 & yas5016>=0 then govdebt=yas5016;
else if yas5015A=2 then do;
if yas5017L>=0 & yas5017U>=yas5017L then govdebt=(yas5017L+yas5017U)/2;
else govdebt=-3;
end;
if yas5015A not in (1,2) or yas5016 in (-1,-2) then do;
if 1<=yas5018<=7 then flag_govdebt=2;
if yas5018=1 then govdebt=500;
else if yas5018=2 then govdebt=1750;
else if yas5018=3 then govdebt=3750;
else if yas5018=4 then govdebt=7500;
else if yas5018=5 then govdebt=17500;
else if yas5018=6 then govdebt=37500;
else if yas5018=7 then govdebt=50001;
end;
end;

if yas5015=-1 or yas5015A=-1 or yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
if yas5015=-2 or yas5015A=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
if yas5015=-3 or yas5015A=-3 or yas5017U=-3 or yas5017L=-3 or yas5018=-3 or yas5016=-3 then govdebt=-3;


************ this is the end of govdebt. ********************************;
*/

****************************************************************************;
*** If the respondent still owes loans to family or relatives, ***;
*** means has been loaned SDLI - famdebt. ***;
****************************************************************************;

array famdebt (20) famdebt01-famdebt20;
array yas5080 (20) yas508001-yas508020;
array yas5082 (20) yas508201-yas508220;
array yas5084L (20) yas5084L01-yas5084L20;
array yas5084U (20) yas5084U01-yas5084U20;
array yas5086 (20) yas508601-yas508620;
array yas5170 (20) yas517001-yas517020;
array yas5172 (20) yas517201-yas517220;
array yas5174L (20) yas5174L01-yas5174L20;
array yas5174U (20) yas5174U01-yas5174U20;
array yas5176 (20) yas517601-yas517620;

array yas5074 (20) yas507401-yas507420;
array yas5164 (20) yas516401-yas516420;

do i=1 to dim(famdebt);
famdebt(i)=-4;
** R was NOT loaned money from family/friends at last assets interview **;
** but has been loaned SDLI. **;
if yas5040=1 then do;
FLAG_famdebt=1.1;
if yas5080(i)=1 & yas5082(i)>=0 then famdebt(i)=yas5082(i);
else if yas5080(i)=2 & yas5084L(i)>=0 & yas5084U(i)>=0
then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
if yas5080(i) not in (1,2) or yas5082(i) in (-1,-2) then do;
if 1<=yas5086(i)<=7 then FLAG_famdebt=2.1;
if yas5086(i)=1 then famdebt(i)=500;
else if yas5086(i)=2 then famdebt(i)=1750;
else if yas5086(i)=3 then famdebt(i)=3750;
else if yas5086(i)=4 then famdebt(i)=7500;
else if yas5086(i)=5 then famdebt(i)=17500;
else if yas5086(i)=6 then famdebt(i)=37500;
else if yas5086(i)=7 then famdebt(i)=50001;
end;
end;
if yas5040=-1 or yas5074(i)=-1 or yas5086(i)=-1 or yas5084L(i)=-1 or yas5084U(i)=-1
then famdebt(i)=-1;
if yas5040=-2 or yas5074(i)=-2 or yas5086(i)=-2 or yas5084L(i)=-2 or yas5084U(i)=-2
then famdebt(i)=-2;
if yas5040=-3 or yas5074(i)=-3 or yas5086(i)=-3 or yas5084L(i)=-3 or yas5084U(i)=-3 or yas5082(i)=-3
then famdebt(i)=-3;

** R was loaned money from family/friends at last assets interview **;
** and has also been loaned SDLI. **;
if yas5130=1 then do;
FLAG_famdebt=1.2;
if yas5170(i)=1 & yas5172(i)>=0 then famdebt(i)=yas5172(i);
else if yas5170(i)=2 & yas5174L(i)>=0 & yas5174U(i)>-0
then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
if yas5170(i) not in (1,2) or yas5172(i) in (-1,-2) then do;
if 1<=yas5176(i)<=7 then FLAG_famdebt=2.2;
if yas5176(i)=1 then famdebt(i)=500;
else if yas5176(i)=2 then famdebt(i)=1750;
else if yas5176(i)=3 then famdebt(i)=3750;
else if yas5176(i)=4 then famdebt(i)=7500;
else if yas5176(i)=5 then famdebt(i)=17500;
else if yas5176(i)=6 then famdebt(i)=37500;
else if yas5176(i)=7 then famdebt(i)=50001;
end;
end;
if yas5130=-1 or yas5164(i)=-1 or yas5176(i)=-1 or yas5174L(i)=-1 or yas5174U(i)=-1
then famdebt(i)=-1;
if yas5130=-2 or yas5164(i)=-2 or yas5176(i)=-2 or yas5174L(i)=-2 or yas5174U(i)=-2
then famdebt(i)=-2;
if yas5130=-3 or yas5164(i)=-3 or yas5176(i)=-3 or yas5174L(i)=-3 or yas5174U(i)=-3 or yas5172(i)=-3
then famdebt(i)=-3;
end;

***************** this is the end of family debts. ************************;



******* Checks for cases when R does not know who lent R the money. *******;
/*
who=0;
if yas5060=1|yas5062=1 then who=1;
if yas5150=1|yas5152=1 then who=2;
*/


****************************************************************;
*** If R or R's partner/spouse jointly have other debts from ***;
*** loans, credit cards, etc. ***;
****************************************************************;

othdebt=-4;
if yas5210=1 then do;
FLAG_othdebt=1;
if yas5220=1 & yas5222>=0 then othdebt=yas5222;
else if yas5220=2 & yas5224L>=0 & yas5224U>=0 then othdebt=(yas5224L+yas5224U)/2;
if yas5220 not in (1,2) or yas5222 in (-1,-2) then do;
if 1<=yas5226<=7 then FLAG_othdebt=2;
if yas5226=1 then othdebt=500;
else if yas5226=2 then othdebt=1750;
else if yas5226=3 then othdebt=3750;
else if yas5226=4 then othdebt=7500;
else if yas5226=5 then othdebt=17500;
else if yas5226=6 then othdebt=37500;
else if yas5226=7 then othdebt=50001;
end;
end;
if yas5210=-1 or yas5224L=-1 or yas5224U=-1 or yas5226=-1 then othdebt=-1;
if yas5210=-2 or yas5224L=-2 or yas5224U=-2 or yas5226=-2 then othdebt=-2;
if yas5210=-3 or yas5224L=-3 or yas5224U=-3 or yas5226=-3 or yas5222=-3 then othdebt=-3;

***************** this is the end of other debts. **************************;

****************************************************************************;
**** THIS IS THE END OF LIABILITIES. ****;
****************************************************************************;




******************************************************************;
***** THIS IS THE END OF DATA CLEANING. *****;
***** THE FOLLOWING IS CALCULATION. *****;
******************************************************************;


************************************************************************;
*** Compute the respondent's household net worth (hhworthY). ***;
*** hhworthY=assets-liabilities. YAST-105 is the question ***;
*** determining whether respondents are asked the assets question. ***;
************************************************************************;

array varsasst (*) pvranch pvmbst pvmb pvst pvapt pvbuss othreal /*items of assets */
retdsav banksav bonds stocks pvcars pvfurn othsav;
array varsliab (*) mortgag resdebt othmort cardebt othdebt
famdebt01-famdebt20; /*items of liabilities */

array flgsasst (*) flag_pvranch flag_pvmbst flag_pvmb flag_pvst flag_pvapt
flag_pvbuss flag_othreal flag_retdsav flag_banksav flag_bonds
flag_stocks flag_pvcars flag_pvfurn flag_othsav;
array flgsliab (*) flag_mortgag flag_resdebt flag_othmort flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

array ahousedebt (*) mortgag resdebt othmort;
array afinance (*) retdsav banksav bonds stocks othsav;
array anonfinance (*) othreal pvcars pvfurn pvbuss;
array adebt (*) cardebt othdebt famdebt01-famdebt20;


array flgshsdt(*) flag_mortgag flag_resdebt flag_othmort;

array flgsfin(*) flag_retdsav flag_banksav flag_bonds flag_stocks flags_othsav;

array flgsnonfin(*) flag_othreal flag_pvcars flag_pvfurn flag_pvbuss;

array flgsdebt(*) flag_cardebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

if yas1400=-4 then do;
hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;
end;

if (yas1400=0 or yas1400=1) then do;

hhworthY=0; assets=0; liabilities=0; housedebt=0;finance=0;nonfinance=0;debt=0;

do i=1 to dim(varsasst);
if varsasst(i)>=0 then assets=assets+varsasst(i);
if varsasst(i) in (-1,-2,-3) then flgsasst(i)=-3;
end;

do i=1 to dim(varsliab);
if varsliab(i)>=0 then liabilities=liabilities+varsliab(i);
if varsliab(i) in (-1,-2,-3) then flgsliab(i)=-3;
end;

hhworthY=assets-liabilities;

do i=1 to dim(ahousedebt);
if ahousedebt(i)>=0 then housedebt=housedebt+ahousedebt(i);
if ahousedebt(i) in (-1,-2,-3) then flgshsdt(i)=-3;
end;
do i=1 to dim(afinance);
if afinance(i)>=0 then finance=finance+afinance(i);
if afinance(i) in (-1, -2, -3) then flgsfin(i)=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)>=0 then nonfinance=nonfinance+anonfinance(i);
if anonfinance(i) in (-1, -2, -3) then flgsnonfin(i)=-3;
end;
do i=1 to dim(adebt);
if adebt(i)>=0 then debt=debt+adebt(i);
if adebt(i) in (-1, -2, -3) then flgsdebt(i)=-3;
end;

end;




*** Code hhworthY as a valid skip for those who were not asked the assets questions;
if yas1400=-4 then do;
hhworthY=-4;
vskpHHY=1;
end;

*** Code hhworthY as an invalid skip for those who did not give valid responses;
do i=1 to dim(varsasst);
if varsasst(i)=-1 then do;
hhworthY=-1;
assets=-1;
invskpHHY=1;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-1 then do;
hhworthY=-1;
invskpHHY=1;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-2 then do;
hhworthY=-2;
assets=-2;
invskpHHY=2;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-2 then do;
hhworthY=-2;
invskpHHY=2;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-3 then do;
hhworthY=-3;
assets=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-3 then do;
hhworthY=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(ahousedebt);
if ahousedebt(i)=-1 then housedebt=-1;
else if ahousedebt(i)=-2 then housedebt=-2;
else if ahousedebt(i)=-3 then housedebt=-3;
end;
do i=1 to dim(afinance);
if afinance(i)=-1 then finance=-1;
else if afinance(i)=-2 then finance=-2;
else if afinance(i)=-3 then finance=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)=-1 then nonfinance=-1;
else if anonfinance(i)=-2 then nonfinance=-2;
else if anonfinance(i)=-3 then nonfinance=-3;
end;
do i=1 to dim(adebt);
if adebt(i)=-1 then debt=-1;
else if adebt(i)=-2 then debt=-2;
else if adebt(i)=-3 then debt=-3;
end;

hhworthY=round(hhworthY,1);
assets=round(assets,1);
housedebt=round(housedebt,1);
house_value=round(house_value,1);
finance=round(finance,1);
nonfinance=round(nonfinance,1);
debt=round(debt,1);


************* Change all the -1s, -2s to -3s. ***************;

array finalv(*) hhworthY assets housedebt house_value finance nonfinance debt;
do i=1 to dim(finalv);
if finalv(i) in (-1,-2) then finalv(i)=-3;
end;

run;

Return to top


Round 7

******************* Start of the Youth Asset Section (hhworthY) ***********************;
* *;
* First create the following components of the hhworthY such as real estate, loans, *;
* cars etc.Each subsection computes one item of the total asset of Youth Respondent *;
* and his/her spouse or partner. Flag variables are created to indicate whether *;
* R/family received that asset item (FLAG_item in (1,2,-3)) and if so was the amount *;
* computed directly from the amount reported by R (FLAG_item=1) or it was computed *;
* from estimates given by R (FLAG_item=2) or it could not be computed (FLAG_item=-3). *;
***************************************************************************************;

libname r7 "C:\My Documents\NLSY97\Round8\Data\r7";
data r7.age20r7;
set r7.r7_20;
round=7;




housing_type=-4;
house_value=-4;


**********************************************************************;
*** If the respondent owns some land, its present value - pvranch. ***;
**********************************************************************;

pvranch=-4;
*** If R alone or R and R's partner/spouse jointly own all of it. ***;
if yas1400=1 & (yas1610=1 or yas1610=2) then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas1860=1 & yas1862>=0 then pvranch=yas1862; /*how about lt 0?*/
else if yas1860=2 & yas1864L>=0 & yas1864U>=0 then do;
if yas1864U>=yas1864L then pvranch=(yas1864L+yas1864U)/2;
else pvranch=-3;
end;
if yas1860 not in (1,2) or yas1862 in (-1,-2) then do;
if 1<=yas1866<=7 then FLAG_pvranch=2;
if yas1866=1 then pvranch=12500;
else if yas1866=2 then pvranch=37500;
else if yas1866=3 then pvranch=75000;
else if yas1866=4 then pvranch=175000;
else if yas1866=5 then pvranch=375000;
else if yas1866=6 then pvranch=750000;
else if yas1866=7 then pvranch=1000001;
end;
end;


*** If R alone or R and R's partner/spouse jointly own part of it (100%). ***;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2140=1 & yas2142>=0 then pvranch=yas2142;
else if yas2140=2 & yas2144L>=0 & yas2144U>=0 then do;
if yas2144U>=yas2144L then pvranch=(yas2144L+yas2144U)/2;
else pvranch=-3;
end;
if yas2140 not in (1,2) or yas2142 in (-1,-2) then do;
if 1<=yas2146<=7 then FLAG_pvranch=2;
if yas2146=1 then pvranch=12500;
else if yas2146=2 then pvranch=37500;
else if yas2146=3 then pvranch=75000;
else if yas2146=4 then pvranch=175000;
else if yas2146=5 then pvranch=375000;
else if yas2146=6 then pvranch=750000;
else if yas2146=7 then pvranch=1000001;
end;
end;


** If R alone or R and R's partner/spouse jointly own part of it (< 100%) **;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120~=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2170=1 & yas2172>=0 then pvranch=yas2172;
else if yas2170=2 & yas2174L>=0 & yas2174U>=0 then do;
if yas2174U>=yas2174L then pvranch=(yas2174L+yas2174U)/2;
else pvranch=-3;
end;
if yas2170 not in (1,2) or yas2172 in (-1,-2) then do;
if 1<=yas2176<=7 then FLAG_pvranch=2;
if yas2176=1 then pvranch=12500;
else if yas2176=2 then pvranch=37500;
else if yas2176=3 then pvranch=75000;
else if yas2176=4 then pvranch=175000;
else if yas2176=5 then pvranch=375000;
else if yas2176=6 then pvranch=750000;
else if yas2176=7 then pvranch=1000001;
end;
end;

if yas1400=-1 or yas1610=-1
or yas1864L=-1 or yas1864U=-1 or yas1866=-1
or yas2144L=-1 or yas2144U=-1 or yas2146=-1
or yas2174L=-1 or yas2174U=-1 or yas2176=-1 then pvranch=-1;

if yas1400=-2 or yas1610=-2
or yas1864L=-2 or yas1864U=-2 or yas1866=-2
or yas2144L=-2 or yas2144U=-2 or yas2146=-2
or yas2174L=-2 or yas2174U=-2 or yas2176=-2 then pvranch=-2;

if yas1400=-3 or yas1610=-3
or yas1864L=-3 or yas1864U=-3 or yas1866=-3
or yas2144L=-3 or yas2144U=-3 or yas2146=-3
or yas2174L=-3 or yas2174U=-3 or yas2176=-3
or yas1862=-3 or yas2142=-3 or yas2172=-3 then pvranch=-3;

if flag_pvranch=1 then do;
housing_type=2;
house_value=pvranch;
end;

if yas1610=6 then do;
housing_type=6;
house_value=-4;
end;

********* this is the end of land part. ***************;


************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home ***;
*** and its site, its present value - pvmbst. ***;
************************************************************************;

pvmbst=-4;
if yas2520 in (1,2) then do;
FLAG_pvmbst=1;
flagck_mbst=1;
if yas2550=1 & yas2552>=0 then pvmbst=yas2552;
else if yas2550=2 & yas2554L>=0 & yas2554U>=0 then do;
if yas2554U>=yas2554L then pvmbst=(yas2554L+yas2554U)/2;
else pvmbst=-3;
end;
if yas2550 not in (1,2) or yas2552 in (-1,-2) then do;
if 1<=yas2556<=7 then FLAG_pvmbst=2;
if yas2556=1 then pvmbst=500;
else if yas2556=2 then pvmbst=1750;
else if yas2556=3 then pvmbst=3750;
else if yas2556=4 then pvmbst=7500;
else if yas2556=5 then pvmbst=17500;
else if yas2556=6 then pvmbst=37500;
else if yas2556=7 then pvmbst=50001;
end;
end;
if yas2520=-1 or yas2554L=-1 or yas2554U=-1 or yas2556=-1 then pvmbst=-1;
if yas2520=-2 or yas2554L=-2 or yas2554U=-2 or yas2556=-2 then pvmbst=-2;
if yas2520=-3 or yas2554L=-3 or yas2554U=-3 or yas2556=-3 or yas2552=-3 then pvmbst=-3;

if flag_pvmbst=1 then do;
housing_type=4;
house_value=pvmbst;
end;

***** this is the end of mobile home & site. *****;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home, ***;
*** its present value - pvmb. ***;
*************************************************************************;

pvmb=-4;
if yas2520 in (3,4) then do;
FLAG_pvmb=1;
flagck_mb=1;
if yas2760=1 & yas2762>=0 then pvmb=yas2762;
else if yas2760=2 & yas2764L>=0 & yas2764U>=0 then do;
if yas2764U>=yas2764L then pvmb=(yas2764L+yas2764U)/2;
else pvmb=-3;
end;
if yas2760 not in (1,2) or yas2762 in (-1,-2) then do;
if 1<=yas2766<=7 then FLAG_pvmb=2;
if yas2766=1 then pvmb=12500;
else if yas2766=2 then pvmb=37500;
else if yas2766=3 then pvmb=75000;
else if yas2766=4 then pvmb=175000;
else if yas2766=5 then pvmb=375000;
else if yas2766=6 then pvmb=750000;
else if yas2766=7 then pvmb=1000001;
end;
end;
if yas2520=-1 or yas2764L=-1 or yas2764U=-1 or yas2766=-1 then pvmb=-1;
if yas2520=-2 or yas2764L=-2 or yas2764U=-2 or yas2766=-2 then pvmb=-2;
if yas2520=-3 or yas2764L=-3 or yas2764U=-3 or yas2766=-3 or yas2762=-3 then pvmb=-3;

if flag_pvmb=1 then do;
housing_type=3;
house_value=pvmb;
end;

******* this is the end of mobile home. ********;


******************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home site, ***;
*** its present value - pvst. ***;
******************************************************************************;

pvst=-4;
if yas2520 in (5,6) then do;
FLAG_pvst=1;
flagck_st=1;
if yas3010=1 & yas3012>=0 then pvst=yas3012;
else if yas3010=2 & yas3014L>=0 & yas3014U>=0 then do;
if yas3014U>=yas3014L then pvst=(yas3014L+yas3014U)/2;
else pvst=-3;
end;
if yas3010 not in (1,2) or yas3012 in (-1,-2) then do;
if 1<=yas3016<=7 then FLAG_pvst=2;
if yas3016=1 then pvst=12500;
else if yas3016=2 then pvst=57500;
else if yas3016=3 then pvst=75000;
else if yas3016=4 then pvst=175000;
else if yas3016=5 then pvst=575000;
else if yas3016=6 then pvst=750000;
else if yas3016=7 then pvst=1000001;
end;
end;
if yas2520=-1 or yas3014L=-1 or yas3014U=-1 or yas3016=-1 then pvst=-1;
if yas2520=-2 or yas3014L=-2 or yas3014U=-2 or yas3016=-2 then pvst=-2;
if yas2520=-3 or yas3014L=-3 or yas3014U=-3 or yas3016=-3 or yas3012=-3 then pvst=-3;

if flag_pvst=1 then do;
housing_type=5;
house_value=pvst;
end;

if yas2520=8 then do;
housing_type=6;
house_value=-4;
end;
******** this is the end of mobile home site. ********;

*******************************************************;
*** THIS IS THE END OF MOBILE HOME & ITS SITE PART. ***;
*******************************************************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own an apartment, ***;
*** its present value - pvapt. ***;
*************************************************************************;

pvapt=-4;
if yas3310 in (1,2) then do;
FLAG_pvapt=1;
flagck_apt=1;
if yas3380=1 & yas3382>=0 then pvapt=yas3382;
else if yas3380=2 & yas3384L>=0 & yas3384U>=0 then do;
if yas3384U>=yas3384L then pvapt=(yas3384L+yas3384U)/2;
else pvapt=-3;
end;
if yas3380 not in (1,2) or yas3382 in (-1,-2) then do;
if 1<=yas3386<=7 then FLAG_pvapt=2;
if yas3386=1 then pvapt=500;
else if yas3386=2 then pvapt=1750;
else if yas3386=3 then pvapt=3750;
else if yas3386=4 then pvapt=7500;
else if yas3386=5 then pvapt=17500;
else if yas3386=6 then pvapt=37500;
else if yas3386=7 then pvapt=50001;
end;
end;
if yas3310=-1 or yas3384L=-1 or yas3384U=-1 or yas3386=-1 then pvapt=-1;
if yas3310=-2 or yas3384L=-2 or yas3384U=-2 or yas3386=-2 then pvapt=-2;
if yas3310=-3 or yas3384L=-3 or yas3384U=-3 or yas3386=-3 or yas3382=-3 then pvapt=-3;

if yas3310 in (1,2) and yas3340=0 then housing_type=1;
else if yas3310 in (1,2) and yas3340=1 and yas3360=1 then housing_type=8;
else if yas3310 in (1,2) and yas3340=1 and yas3360=2 then housing_type=7;

if flag_pvapt=1 then house_value=pvapt;

if yas3310=4 then do;
housing_type=6;
house_value=0;
end;

/*************************************************************/

/*************************************************************/

********** this is the end of apartment part. *********************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a business, ***;
*** partnership or professional practice, its present value - pvbuss. ***;
*************************************************************************;

pvbuss=-4;
if yas4010 in (1,2) then do;
FLAG_pvbuss=1;
if yas4030=1 & yas4032>=0 then pvbuss=yas4032;
else if yas4030=2 then pvbuss=(yas4034L+yas4034U)/2;
if yas4030 not in (1,2) or yas4032 in (-1,-2) then do;
if 1<=yas4036<=7 then FLAG_pvbuss=2;
if yas4036=1 then pvbuss=12500;
else if yas4036=2 then pvbuss=37500;
else if yas4036=3 then pvbuss=75000;
else if yas4036=4 then pvbuss=175000;
else if yas4036=5 then pvbuss=375000;
else if yas4036=6 then pvbuss=750000;
else if yas4036=7 then pvbuss=1000001;
end;
end;
if yas4010=-1 or yas4034L=-1 or yas4034U=-1 or yas4036=-1 then pvbuss=-1;
if yas4010=-2 or yas4034L=-2 or yas4034U=-2 or yas4036=-2 then pvbuss=-2;
if yas4010=-3 or yas4034L=-3 or yas4034U=-3 or yas4036=-3 or yas4032=-3 then pvbuss=-3;

********* this is the end of business part. *****************;


*******************************************************************;
*** If R alone or R and R's partner/spouse jointly own a second ***;
*** real estate, its present value - othreal. ***;
*******************************************************************;

othreal=-4;
if yas4140 in (1,2) then do;
FLAG_othreal=1;
if yas4160=1 & yas4162>=0 then othreal=yas4162;
else if yas4160=2 then othreal=(yas4164L+yas4164U)/2;
if yas4160 not in (1,2) or yas4162 in (-1,-2) then do;
if 1<=yas4166<=7 then FLAG_othreal=2;
if yas4166=1 then othreal=12500;
else if yas4166=2 then othreal=37500;
else if yas4166=3 then othreal=75000;
else if yas4166=4 then othreal=175000;
else if yas4166=5 then othreal=375000;
else if yas4166=6 then othreal=750000;
else if yas4166=7 then othreal=1000001;
end;
end;
if yas4140=-1 or yas4164L=-1 or yas4164U=-1 or yas4166=-1 then othreal=-1;
if yas4140=-2 or yas4164L=-2 or yas4164U=-2 or yas4166=-2 then othreal=-2;
if yas4140=-3 or yas4164L=-3 or yas4164U=-3 or yas4166=-3 or yas4162=-3 then othreal=-3;

**************** this is the end of other real estate. ********************;


******************************************************************************;
*** If R or R's partner/spouse have retirement plans or pensions - retdsav ***;
******************************************************************************;

retdsav=-4;
if yas4270 in (1,2,3) then do;
FLAG_retdsav=1;
if yas4290=1 & yas4292>=0 then retdsav=yas4292;
else if yas4290=2 & yas4294U>=0 & yas4294L>=0 then retdsav=(yas4294L+yas4294U)/2;
if yas4290 not in (1,2) or yas4292 in (-1,-2) then do;
if 1<=yas4296<=7 then FLAG_retdsav=2;
if yas4296=1 then retdsav=2500;
else if yas4296=2 then retdsav=7500;
else if yas4296=3 then retdsav=17500;
else if yas4296=4 then retdsav=37500;
else if yas4296=5 then retdsav=75000;
else if yas4296=6 then retdsav=175000;
else if yas4296=7 then retdsav=250001;
end;
end;
if yas4270=-1 or yas4294L=-1 or yas4294U=-1 or yas4296=-1 then retdsav=-1;
if yas4270=-2 or yas4294L=-2 or yas4294U=-2 or yas4296=-2 then retdsav=-2;
if yas4270=-3 or yas4294L=-3 or yas4294U=-3 or yas4296=-3 or yas4292=-3 then retdsav=-3;

******** this is the end of retirement plans. ****************;


*******************************************************************;
*** If R or R's partner/spouse have banksav in saving accounts, ***;
*** money market, funds,trusts, - banksav. ***;
*******************************************************************;

banksav=-4;
if yas4400 in (1,2,3) then do;
FLAG_banksav=1;
if yas4420=1 & yas4422>=0 then banksav=yas4422;
else if yas4420=2 & yas4424U>=0 & yas4424L>=0 then do;
if yas4424U>=yas4424L then banksav=(yas4424L+yas4424U)/2;
else banksav=-3;
end;
if yas4420 not in (1,2) or yas4422 in (-1,-2) then do;
if 1<=yas4426<=7 then FLAG_banksav=2;
if yas4426=1 then banksav=500;
else if yas4426=2 then banksav=1750;
else if yas4426=3 then banksav=3750;
else if yas4426=4 then banksav=7500;
else if yas4426=5 then banksav=17500;
else if yas4426=6 then banksav=37500;
else if yas4426=7 then banksav=50001;
end;
end;
if yas4400=-1 or yas4424L=-1 or yas4424U=-2 or yas4426=-1 then banksav=-1;
if yas4400=-2 or yas4424L=-2 or yas4424U=-2 or yas4426=-2 then banksav=-2;
if yas4400=-3 or yas4424L=-3 or yas4424U=-3 or yas4426=-3 or yas4422=-3 then banksav=-3;

************* this is the end of bank savings. ****************;


******************************************************************************;
*** If R or R's partner/spouse have other banksav in bonds or cds - bonds. ***;
******************************************************************************;

bonds=-4;
if yas4530 in (1,2,3) then do;
FLAG_bonds=1;
if yas4550=1 & yas4552>=0 then bonds=yas4552;
else if yas4550=2 & yas4554U>=0 & yas4554L>=0 then bonds=(yas4554L+yas4554U)/2;
if yas4550 not in (1,2) or yas4552 in (-1,-2) then do;
if 1<=yas4556<=7 then FLAG_bonds=2;
if yas4556=1 then bonds=500;
else if yas4556=2 then bonds=1750;
else if yas4556=3 then bonds=3750;
else if yas4556=4 then bonds=7500;
else if yas4556=5 then bonds=17500;
else if yas4556=6 then bonds=37500;
else if yas4556=7 then bonds=50001;
end;
end;
if yas4530=-1 or yas4554L=-1 or yas4554U=-1 or yas4556=-1 then bonds=-1;
if yas4530=-2 or yas4554L=-2 or yas4554U=-2 or yas4556=-2 then bonds=-2;
if yas4530=-3 or yas4554L=-3 or yas4554U=-3 or yas4556=-3 or yas4552=-3 then bonds=-3;

***************** this is the end of bonds. **********************;


*** If the respondent or his/her partner/spouse have stocks, mutual funds - stocks;

stocks=-4;
if yas4660 in (1,2,3) then do;
FLAG_stocks=1;
if yas4680=1 & yas4682>=0 then stocks=yas4682;
else if yas4680=2 & yas4684L>=0 & yas4684U>=0 then stocks=(yas4684L+yas4684U)/2;
if yas4680 not in (1,2) or yas4682 in (-1,-2) then do;
if 1<=yas4686<=7 then FLAG_stocks=2;
if yas4686=1 then stocks=500;
else if yas4686=2 then stocks=1750;
else if yas4686=3 then stocks=3750;
else if yas4686=4 then stocks=7500;
else if yas4686=5 then stocks=17500;
else if yas4686=6 then stocks=37500;
else if yas4686=7 then stocks=50001;
end;
end;
if yas4660=-1 or yas4684L=-1 or yas4684U=-1 or yas4686=-1 then stocks=-1;
if yas4660=-2 or yas4684L=-2 or yas4684U=-2 or yas4686=-2 then stocks=-2;
if yas4660=-3 or yas4684L=-3 or yas4684U=-3 or yas4686=-3 or yas4682=-3 then stocks=-3;

****************** this is the end of stocks. ***********************;


************************************************************************;
*** If the respondent alone or respondent and his/her partner/spouse ***;
*** jointly own vehicles, their present value - pvcars. ***;
************************************************************************;

pvcars=-4;
if yas4790 in (1,2,3) then do;
FLAG_pvcars=1;
if yas4810=1 & yas4812>=0 then pvcars=yas4812;
else if yas4810=2 & yas4814L>=0 & yas4814U>=0 then pvcars=(yas4814L+yas4814U)/2;
if yas4810 not in (1,2) or yas4812 in (-1,-2) then do;
if 1<=yas4816<=7 then FLAG_pvcars=2;
if yas4816=1 then pvcars=2500;
else if yas4816=2 then pvcars=7500;
else if yas4816=3 then pvcars=17500;
else if yas4816=4 then pvcars=37500;
else if yas4816=5 then pvcars=75000;
else if yas4816=6 then pvcars=175000;
else if yas4816=7 then pvcars=250001;
end;
end;
if yas4790=-1 or yas4814L=-1 or yas4814U=-1 or yas4816=-1 then pvcars=-1;
if yas4790=-2 or yas4814L=-2 or yas4814U=-2 or yas4816=-2 then pvcars=-2;
if yas4790=-3 or yas4814L=-3 or yas4814U=-3 or yas4816=-3 or yas4812=-3 then pvcars=-3;

***************** this is the end of vehicles part. **********************;


*********************************************************************;
*** If R alone or R and R's partner/spouse jointly own furniture, ***;
*** its present value - pvfurn. ***;
*********************************************************************;

pvfurn=-4;
if yas4870>-4 then FLAG_pvfurn=1;
if yas4870=1 then pvfurn=2500;
else if yas4870=2 then pvfurn=7500;
else if yas4870=3 then pvfurn=17500;
else if yas4870=4 then pvfurn=37500;
else if yas4870=5 then pvfurn=75000;
else if yas4870=6 then pvfurn=175000;
else if yas4870=7 then pvfurn=250001;
else if yas4870=-1 then pvfurn=-1;
else if yas4870=-2 then pvfurn=-2;
else if yas4870=-3 then pvfurn=-3;

************** this is the end of furniture part. *****************;


***************************************************************************;
*** If R alone or R and R's partner/spouse jointly own other assets not ***;
*** mentioned before - othsav. ********************************************;
***************************************************************************;

othsav=-4;
if yas4880 in (1,2,3) then do;
FLAG_othsav=1;
if yas4900=1 & yas4902>=0 then othsav=yas4902;
else if yas4900=2 & yas4904L>=0 & yas4904U>=0 then othsav=(yas4904L+yas4904U)/2;
if yas4900 not in (1,2) or yas4902 in (-1,-2) then do;
if 1<=yas4906<=7 then FLAG_othsav=2;
if yas4906=1 then othsav=2500;
else if yas4906=2 then othsav=7500;
else if yas4906=3 then othsav=17500;
else if yas4906=4 then othsav=37500;
else if yas4906=5 then othsav=75000;
else if yas4906=6 then othsav=175000;
else if yas4906=7 then othsav=250001;
end;
end;
if yas4880=-1 or yas4904L=-1 or yas4904U=-1 or yas4906=-1 then othsav=-1;
if yas4880=-2 or yas4904L=-2 or yas4904U=-2 or yas4906=-2 then othsav=-2;
if yas4880=-3 or yas4904L=-3 or yas4904U=-3 or yas4906=-3 or yas4902=-3 then othsav=-3;

************** this is the end of other savings. **********************;



*************************************************************************;
**** THIS IS THE END OF ASSETS. ****;
**** THE FOLLOWING IS LIABILITIES. ****;
*************************************************************************;



***********************************************************************;
*** If there is mortgage or land contract on the aforementioned land ***;
*** or property - mortgag. ***;
***********************************************************************;

mortgag=-4;
if yas3740 in (1,2) then do;
FLAG_mortgag=1;
if yas3750=1 & yas3752>=0 then mortgag=yas3752;
else if yas3750=2 & yas3754L>=0 & yas3754U>=0 then mortgag=(yas3754L+yas3754U)/2;
if yas3750 not in (1,2) or yas3752 in (-1,-2) then do;
if 1<=yas3756<=7 then FLAG_mortgag=2;
if yas3756=1 then mortgag=500;
else if yas3756=2 then mortgag=1750;
else if yas3756=3 then mortgag=3750;
else if yas3756=4 then mortgag=7500;
else if yas3756=5 then mortgag=17500;
else if yas3756=6 then mortgag=37500;
else if yas3756=7 then mortgag=50001;
end;
end;
if yas3740=-1 or yas3754L=-1 or yas3754U=-1 or yas3756=-1 then mortgag=-1;
if yas3740=-2 or yas3754L=-2 or yas3754U=-2 or yas3756=-2 then mortgag=-2;
if yas3740=-3 or yas3754L=-3 or yas3754U=-3 or yas3756=-3 or yas3752>=0 then mortgag=-3;

***************** this is the end of mortgage part. *******************;


*****************************************************************;
*** If R or R's partner/spouse has unpaid loans from Round 7 ***;
*** (yas3840=1 & yas3850=1) or still owes loans taken SDLI on ***;
*** house (yas3860=1) then total amount owed - resdebt. ***;
*****************************************************************;

resdebt=-4;
if (yas3840=1 & yas3850=1) or yas3860=1 then do;
FLAG_resdebt=1;
if yas3880=1 & yas3882>=0 then resdebt=yas3882;
else if yas3880=2 & yas3884U>=0 & yas3884L>=0 then resdebt=(yas3884L+yas3884U)/2;
if yas3880 not in (1,2) or yas3882 in (-1,-2) then do;
if 1<=yas3886<=7 then FLAG_resdebt=2;
if yas3886=1 then resdebt=500;
else if yas3886=2 then resdebt=1750;
else if yas3886=3 then resdebt=3750;
else if yas3886=4 then resdebt=7500;
else if yas3886=5 then resdebt=17500;
else if yas3886=6 then resdebt=37500;
else if yas3886=7 then resdebt=50001;
end;
end;
if yas3850=-1 or yas3860=-1 or yas3884L=-1 or yas3884U=-1 or yas3886=-1
then resdebt=-1;
if yas3850=-2 or yas3860=-2 or yas3884L=-2 or yas3884U=-2 or yas3886=-2
then resdebt=-2;
if yas3850=-3 or yas3860=-3 or yas3884L=-3 or yas3884U=-3 or yas3886=-3 or yas3882=-3
then resdebt=-3;

************** this is the end of resdebt. ****************;


***************************************************************;
*** If the respondent or his/her partner/spouse have second ***;
*** mortgages - othmort. ***;
***************************************************************;

othmort=-4;
if yas3910=1 then do;
FLAG_othmort=1;
if yas3920=1 & yas3922>=0 then othmort=yas3922;
else if yas3920=2 & yas3924U>=0 & yas3924L>=0 then othmort=(yas3924L+yas3924U)/2;
if yas3920 not in (1,2) or yas3922 in (-1,-2) then do;
if 1<=yas3926<=7 then FLAG_othmort=2;
if yas3926=1 then othmort=500;
else if yas3926=2 then othmort=1750;
else if yas3926=3 then othmort=3750;
else if yas3926=4 then othmort=7500;
else if yas3926=5 then othmort=17500;
else if yas3926=6 then othmort=37500;
else if yas3926=7 then othmort=50001;
end;
end;
if yas3910=-1 or yas3924L=-1 or yas3924U=-1 or yas3926=-1 then othmort=-1;
if yas3910=-2 or yas3924L=-2 or yas3924U=-2 or yas3926=-2 then othmort=-2;
if yas3910=-3 or yas3924L=-3 or yas3924U=-3 or yas3926=-3 or yas3922=-3 then othmort=-3;

********** this is the end of other mortgage. ******************;


*******************************************************************************;
*** If R or R's partner/spouse still owe money on these vehicles - cardebt. ***;
*******************************************************************************;

cardebt=-4;
if yas4840>-4 then FLAG_cardebt=1;
if yas4840=1 & yas4842>=0 then cardebt=yas4842;
else if yas4840=2 & yas4844L>=0 & yas4844U>=0 then cardebt=(yas4844L+yas4844U)/2;
if yas4840 not in (1,2) or yas4842 in (-1,-2) then do;
if 1<=yas4846<=7 then FLAG_cardebt=2;
if yas4846=1 then cardebt=2500;
else if yas4846=2 then cardebt=7500;
else if yas4846=3 then cardebt=17500;
else if yas4846=4 then cardebt=37500;
else if yas4846=5 then cardebt=75000;
else if yas4846=6 then cardebt=175000;
else if yas4846=7 then cardebt=250001;
end;
if yas4790=-1 or yas4844L=-1 or yas4844U=-1 or yas4846=-1 then cardebt=-1;
if yas4790=-2 or yas4844L=-2 or yas4844U=-2 or yas4846=-2 then cardebt=-2;
if yas4790=-3 or yas4844L=-3 or yas4844U=-3 or yas4846=-3 or yas4842=-3 then cardebt=-3;

**************** this is the end of car debt. **********************;


*************************famedudebt**********************************;

famedudebt=-4;
if yas5011=1 then do;
flag_famedudebt=1;
if yas5011A=1 & yas5012>=0 then famedudebt=yas5012;
else if yas5011A=2 then do;
if yas5013L>=0 & yas5013U>=yas5013L then famedudebt=(yas5013L+yas5013U)/2;
else famedudebt=-3;
end;
if yas5011A not in (1,2) or yas5012 in (-1,-2) then do;
if 1<=yas5014<=7 then flag_famedudebt=2;
if yas5014=1 then famedudebt=500;
else if yas5014=2 then famedudebt=1750;
else if yas5014=3 then famedudebt=3750;
else if yas5014=4 then famedudebt=7500;
else if yas5014=5 then famedudebt=17500;
else if yas5014=6 then famedudebt=37500;
else if yas5014=7 then famedudebt=50001;
end;
end;

if yas5011=-1 or yas5011A=-1 or yas5013U=-1 or yas5013L=-1 or yas5014=-1 then famedudebt=-1;
if yas5011=-2 or yas5011A=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2 then famedudebt=-2;
if yas5011=-3 or yas5011A=-3 or yas5013U=-3 or yas5013L=-3 or yas5014=-3 or yas5012=-3 then famedudebt=-3;

*******************************************************************************************;

********************** Government loan *****************************;

govdebt=-4;
if yas5015=1 then do;
flag_govdebt=-4;
if yas5015A=1 & yas5016>=0 then govdebt=yas5016;
else if yas5015A=2 then do;
if yas5017L>=0 & yas5017U>=yas5017L then govdebt=(yas5017L+yas5017U)/2;
else govdebt=-3;
end;
if yas5015A not in (1,2) or yas5016 in (-1,-2) then do;
if 1<=yas5018<=7 then flag_govdebt=2;
if yas5018=1 then govdebt=500;
else if yas5018=2 then govdebt=1750;
else if yas5018=3 then govdebt=3750;
else if yas5018=4 then govdebt=7500;
else if yas5018=5 then govdebt=17500;
else if yas5018=6 then govdebt=37500;
else if yas5018=7 then govdebt=50001;
end;
end;

if yas5015=-1 or yas5015A=-1 or yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
if yas5015=-2 or yas5015A=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
if yas5015=-3 or yas5015A=-3 or yas5017U=-3 or yas5017L=-3 or yas5018=-3 or yas5016=-3 then govdebt=-3;


************ this is the end of govdebt. ********************************;


****************************************************************************;
*** If the respondent still owes loans to family or relatives, ***;
*** means has been loaned SDLI - famdebt. ***;
****************************************************************************;

array famdebt (20) famdebt01-famdebt20;
array yas5080 (20) yas508001-yas508020;
array yas5082 (20) yas508201-yas508220;
array yas5084L (20) yas5084L01-yas5084L20;
array yas5084U (20) yas5084U01-yas5084U20;
array yas5086 (20) yas508601-yas508620;
array yas5170 (20) yas517001-yas517020;
array yas5172 (20) yas517201-yas517220;
array yas5174L (20) yas5174L01-yas5174L20;
array yas5174U (20) yas5174U01-yas5174U20;
array yas5176 (20) yas517601-yas517620;

array yas5074 (20) yas507401-yas507420;
array yas5164 (20) yas516401-yas516420;

do i=1 to dim(famdebt);
famdebt(i)=-4;
** R was NOT loaned money from family/friends at last assets interview **;
** but has been loaned SDLI. **;
if yas5040=1 then do;
FLAG_famdebt=1.1;
if yas5080(i)=1 & yas5082(i)>=0 then famdebt(i)=yas5082(i);
else if yas5080(i)=2 & yas5084L(i)>=0 & yas5084U(i)>=0
then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
if yas5080(i) not in (1,2) or yas5082(i) in (-1,-2) then do;
if 1<=yas5086(i)<=7 then FLAG_famdebt=2.1;
if yas5086(i)=1 then famdebt(i)=500;
else if yas5086(i)=2 then famdebt(i)=1750;
else if yas5086(i)=3 then famdebt(i)=3750;
else if yas5086(i)=4 then famdebt(i)=7500;
else if yas5086(i)=5 then famdebt(i)=17500;
else if yas5086(i)=6 then famdebt(i)=37500;
else if yas5086(i)=7 then famdebt(i)=50001;
end;
end;
if yas5040=-1 or yas5074(i)=-1 or yas5086(i)=-1 or yas5084L(i)=-1 or yas5084U(i)=-1
then famdebt(i)=-1;
if yas5040=-2 or yas5074(i)=-2 or yas5086(i)=-2 or yas5084L(i)=-2 or yas5084U(i)=-2
then famdebt(i)=-2;
if yas5040=-3 or yas5074(i)=-3 or yas5086(i)=-3 or yas5084L(i)=-3 or yas5084U(i)=-3 or yas5082(i)=-3
then famdebt(i)=-3;

** R was loaned money from family/friends at last assets interview **;
** and has also been loaned SDLI. **;
if yas5130=1 then do;
FLAG_famdebt=1.2;
if yas5170(i)=1 & yas5172(i)>=0 then famdebt(i)=yas5172(i);
else if yas5170(i)=2 & yas5174L(i)>=0 & yas5174U(i)>-0
then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
if yas5170(i) not in (1,2) or yas5172(i) in (-1,-2) then do;
if 1<=yas5176(i)<=7 then FLAG_famdebt=2.2;
if yas5176(i)=1 then famdebt(i)=500;
else if yas5176(i)=2 then famdebt(i)=1750;
else if yas5176(i)=3 then famdebt(i)=3750;
else if yas5176(i)=4 then famdebt(i)=7500;
else if yas5176(i)=5 then famdebt(i)=17500;
else if yas5176(i)=6 then famdebt(i)=37500;
else if yas5176(i)=7 then famdebt(i)=50001;
end;
end;
if yas5130=-1 or yas5164(i)=-1 or yas5176(i)=-1 or yas5174L(i)=-1 or yas5174U(i)=-1
then famdebt(i)=-1;
if yas5130=-2 or yas5164(i)=-2 or yas5176(i)=-2 or yas5174L(i)=-2 or yas5174U(i)=-2
then famdebt(i)=-2;
if yas5130=-3 or yas5164(i)=-3 or yas5176(i)=-3 or yas5174L(i)=-3 or yas5174U(i)=-3 or yas5172(i)=-3
then famdebt(i)=-3;
end;

***************** this is the end of family debts. ************************;



******* Checks for cases when R does not know who lent R the money. *******;
/*
who=0;
if yas5060=1|yas5062=1 then who=1;
if yas5150=1|yas5152=1 then who=2;
*/


****************************************************************;
*** If R or R's partner/spouse jointly have other debts from ***;
*** loans, credit cards, etc. ***;
****************************************************************;

othdebt=-4;
if yas5210=1 then do;
FLAG_othdebt=1;
if yas5220=1 & yas5222>=0 then othdebt=yas5222;
else if yas5220=2 & yas5224L>=0 & yas5224U>=0 then othdebt=(yas5224L+yas5224U)/2;
if yas5220 not in (1,2) or yas5222 in (-1,-2) then do;
if 1<=yas5226<=7 then FLAG_othdebt=2;
if yas5226=1 then othdebt=500;
else if yas5226=2 then othdebt=1750;
else if yas5226=3 then othdebt=3750;
else if yas5226=4 then othdebt=7500;
else if yas5226=5 then othdebt=17500;
else if yas5226=6 then othdebt=37500;
else if yas5226=7 then othdebt=50001;
end;
end;
if yas5210=-1 or yas5224L=-1 or yas5224U=-1 or yas5226=-1 then othdebt=-1;
if yas5210=-2 or yas5224L=-2 or yas5224U=-2 or yas5226=-2 then othdebt=-2;
if yas5210=-3 or yas5224L=-3 or yas5224U=-3 or yas5226=-3 or yas5222=-3 then othdebt=-3;

***************** this is the end of other debts. **************************;

****************************************************************************;
**** THIS IS THE END OF LIABILITIES. ****;
****************************************************************************;




******************************************************************;
***** THIS IS THE END OF DATA CLEANING. *****;
***** THE FOLLOWING IS CALCULATION. *****;
******************************************************************;


************************************************************************;
*** Compute the respondent's household net worth (hhworthY). ***;
*** hhworthY=assets-liabilities. YAST-105 is the question ***;
*** determining whether respondents are asked the assets question. ***;
************************************************************************;

array varsasst (*) pvranch pvmbst pvmb pvst pvapt pvbuss othreal /*items of assets */
retdsav banksav bonds stocks pvcars pvfurn othsav;
array varsliab (*) mortgag resdebt othmort cardebt famedudebt govdebt othdebt
famdebt01-famdebt20; /*items of liabilities */

array flgsasst (*) flag_pvranch flag_pvmbst flag_pvmb flag_pvst flag_pvapt
flag_pvbuss flag_othreal flag_retdsav flag_banksav flag_bonds
flag_stocks flag_pvcars flag_pvfurn flag_othsav;
array flgsliab (*) flag_mortgag flag_resdebt flag_othmort flag_cardebt flag_famedudebt flag_govdebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

array ahousedebt (*) mortgag resdebt othmort;
array afinance (*) retdsav banksav bonds stocks othsav;
array anonfinance (*) othreal pvcars pvfurn pvbuss;
array adebt (*) cardebt famedudebt govdebt othdebt famdebt01-famdebt20;


array flgshsdt(*) flag_mortgag flag_resdebt flag_othmort;

array flgsfin(*) flag_retdsav flag_banksav flag_bonds flag_stocks flags_othsav;

array flgsnonfin(*) flag_othreal flag_pvcars flag_pvfurn flag_pvbuss;

array flgsdebt(*) flag_cardebt flag_famedudebt flag_govdebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

if yas1400=-4 then do;
hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;
end;

if (yas1400=0 or yas1400=1) then do;

hhworthY=0; assets=0; liabilities=0; housedebt=0;finance=0;nonfinance=0;debt=0;

do i=1 to dim(varsasst);
if varsasst(i)>=0 then assets=assets+varsasst(i);
if varsasst(i) in (-1,-2,-3) then flgsasst(i)=-3;
end;

do i=1 to dim(varsliab);
if varsliab(i)>=0 then liabilities=liabilities+varsliab(i);
if varsliab(i) in (-1,-2,-3) then flgsliab(i)=-3;
end;

hhworthY=assets-liabilities;

do i=1 to dim(ahousedebt);
if ahousedebt(i)>=0 then housedebt=housedebt+ahousedebt(i);
if ahousedebt(i) in (-1,-2,-3) then flgshsdt(i)=-3;
end;
do i=1 to dim(afinance);
if afinance(i)>=0 then finance=finance+afinance(i);
if afinance(i) in (-1, -2, -3) then flgsfin(i)=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)>=0 then nonfinance=nonfinance+anonfinance(i);
if anonfinance(i) in (-1, -2, -3) then flgsnonfin(i)=-3;
end;
do i=1 to dim(adebt);
if adebt(i)>=0 then debt=debt+adebt(i);
if adebt(i) in (-1, -2, -3) then flgsdebt(i)=-3;
end;

end;




*** Code hhworthY as a valid skip for those who were not asked the assets questions;
if yas1400=-4 then do;
hhworthY=-4;
vskpHHY=1;
end;

*** Code hhworthY as an invalid skip for those who did not give valid responses;
do i=1 to dim(varsasst);
if varsasst(i)=-1 then do;
hhworthY=-1;
assets=-1;
invskpHHY=1;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-1 then do;
hhworthY=-1;
invskpHHY=1;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-2 then do;
hhworthY=-2;
assets=-2;
invskpHHY=2;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-2 then do;
hhworthY=-2;
invskpHHY=2;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-3 then do;
hhworthY=-3;
assets=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-3 then do;
hhworthY=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(ahousedebt);
if ahousedebt(i)=-1 then housedebt=-1;
else if ahousedebt(i)=-2 then housedebt=-2;
else if ahousedebt(i)=-3 then housedebt=-3;
end;
do i=1 to dim(afinance);
if afinance(i)=-1 then finance=-1;
else if afinance(i)=-2 then finance=-2;
else if afinance(i)=-3 then finance=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)=-1 then nonfinance=-1;
else if anonfinance(i)=-2 then nonfinance=-2;
else if anonfinance(i)=-3 then nonfinance=-3;
end;
do i=1 to dim(adebt);
if adebt(i)=-1 then debt=-1;
else if adebt(i)=-2 then debt=-2;
else if adebt(i)=-3 then debt=-3;
end;

hhworthY=round(hhworthY,1);
assets=round(assets,1);
housedebt=round(housedebt,1);
house_value=round(house_value,1);
finance=round(finance,1);
nonfinance=round(nonfinance,1);
debt=round(debt,1);

************* Change all the -1s, -2s to -3s. ***************;

array finalv(*) hhworthY assets housedebt house_value finance nonfinance debt;
do i=1 to dim(finalv);
if finalv(i) in (-1,-2) then finalv(i)=-3;
end;

run;

Return to top


Round 8

******************* Start of the Youth Asset Section (hhworthY) ***********************;
* *;
* First create the following components of the hhworthY such as real estate, loans, *;
* cars etc.Each subsection computes one item of the total asset of Youth Respondent *;
* and his/her spouse or partner. Flag variables are created to indicate whether *;
* R/family received that asset item (FLAG_item in (1,2,-3)) and if so was the amount *;
* computed directly from the amount reported by R (FLAG_item=1) or it was computed *;
* from estimates given by R (FLAG_item=2) or it could not be computed (FLAG_item=-3). *;
***************************************************************************************;

libname r8 "C:\My Documents\NLSY97\Round8\Data\r8";
data r8.age20r8;
set r8.r8_20;
round=8;




housing_type=-4;
house_value=-4;


**********************************************************************;
*** If the respondent owns some land, its present value - pvranch. ***;
**********************************************************************;

pvranch=-4;
*** If R alone or R and R's partner/spouse jointly own all of it. ***;
if yas1400=1 & (yas1610=1 or yas1610=2) then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas1860=1 & yas1862>=0 then pvranch=yas1862; /*how about lt 0?*/
else if yas1860=2 & yas1864L>=0 & yas1864U>=0 then do;
if yas1864U>=yas1864L then pvranch=(yas1864L+yas1864U)/2;
else pvranch=-3;
end;
if yas1860 not in (1,2) or yas1862 in (-1,-2) then do;
if 1<=yas1866<=7 then FLAG_pvranch=2;
if yas1866=1 then pvranch=12500;
else if yas1866=2 then pvranch=37500;
else if yas1866=3 then pvranch=75000;
else if yas1866=4 then pvranch=175000;
else if yas1866=5 then pvranch=375000;
else if yas1866=6 then pvranch=750000;
else if yas1866=7 then pvranch=1000001;
end;
end;


*** If R alone or R and R's partner/spouse jointly own part of it (100%). ***;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2140=1 & yas2142>=0 then pvranch=yas2142;
else if yas2140=2 & yas2144L>=0 & yas2144U>=0 then do;
if yas2144U>=yas2144L then pvranch=(yas2144L+yas2144U)/2;
else pvranch=-3;
end;
if yas2140 not in (1,2) or yas2142 in (-1,-2) then do;
if 1<=yas2146<=7 then FLAG_pvranch=2;
if yas2146=1 then pvranch=12500;
else if yas2146=2 then pvranch=37500;
else if yas2146=3 then pvranch=75000;
else if yas2146=4 then pvranch=175000;
else if yas2146=5 then pvranch=375000;
else if yas2146=6 then pvranch=750000;
else if yas2146=7 then pvranch=1000001;
end;
end;


** If R alone or R and R's partner/spouse jointly own part of it (< 100%) **;
if yas1400=1 & (yas1610=3|yas1610=4) & yas2120~=100 then do;
FLAG_pvranch=1;
flagck_ranch=1;
if yas2170=1 & yas2172>=0 then pvranch=yas2172;
else if yas2170=2 & yas2174L>=0 & yas2174U>=0 then do;
if yas2174U>=yas2174L then pvranch=(yas2174L+yas2174U)/2;
else pvranch=-3;
end;
if yas2170 not in (1,2) or yas2172 in (-1,-2) then do;
if 1<=yas2176<=7 then FLAG_pvranch=2;
if yas2176=1 then pvranch=12500;
else if yas2176=2 then pvranch=37500;
else if yas2176=3 then pvranch=75000;
else if yas2176=4 then pvranch=175000;
else if yas2176=5 then pvranch=375000;
else if yas2176=6 then pvranch=750000;
else if yas2176=7 then pvranch=1000001;
end;
end;

if yas1400=-1 or yas1610=-1
or yas1864L=-1 or yas1864U=-1 or yas1866=-1
or yas2144L=-1 or yas2144U=-1 or yas2146=-1
or yas2174L=-1 or yas2174U=-1 or yas2176=-1 then pvranch=-1;

if yas1400=-2 or yas1610=-2
or yas1864L=-2 or yas1864U=-2 or yas1866=-2
or yas2144L=-2 or yas2144U=-2 or yas2146=-2
or yas2174L=-2 or yas2174U=-2 or yas2176=-2 then pvranch=-2;

if yas1400=-3 or yas1610=-3
or yas1864L=-3 or yas1864U=-3 or yas1866=-3
or yas2144L=-3 or yas2144U=-3 or yas2146=-3
or yas2174L=-3 or yas2174U=-3 or yas2176=-3
or yas1862=-3 or yas2142=-3 or yas2172=-3 then pvranch=-3;

if flag_pvranch=1 then do;
housing_type=2;
house_value=pvranch;
end;

if yas1610=6 then do;
housing_type=6;
house_value=-4;
end;

********* this is the end of land part. ***************;


************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home ***;
*** and its site, its present value - pvmbst. ***;
************************************************************************;

pvmbst=-4;
if yas2520 in (1,2) then do;
FLAG_pvmbst=1;
flagck_mbst=1;
if yas2550=1 & yas2552>=0 then pvmbst=yas2552;
else if yas2550=2 & yas2554L>=0 & yas2554U>=0 then do;
if yas2554U>=yas2554L then pvmbst=(yas2554L+yas2554U)/2;
else pvmbst=-3;
end;
if yas2550 not in (1,2) or yas2552 in (-1,-2) then do;
if 1<=yas2556<=7 then FLAG_pvmbst=2;
if yas2556=1 then pvmbst=500;
else if yas2556=2 then pvmbst=1750;
else if yas2556=3 then pvmbst=3750;
else if yas2556=4 then pvmbst=7500;
else if yas2556=5 then pvmbst=17500;
else if yas2556=6 then pvmbst=37500;
else if yas2556=7 then pvmbst=50001;
end;
end;
if yas2520=-1 or yas2554L=-1 or yas2554U=-1 or yas2556=-1 then pvmbst=-1;
if yas2520=-2 or yas2554L=-2 or yas2554U=-2 or yas2556=-2 then pvmbst=-2;
if yas2520=-3 or yas2554L=-3 or yas2554U=-3 or yas2556=-3 or yas2552=-3 then pvmbst=-3;

if flag_pvmbst=1 then do;
housing_type=4;
house_value=pvmbst;
end;

***** this is the end of mobile home & site. *****;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home, ***;
*** its present value - pvmb. ***;
*************************************************************************;

pvmb=-4;
if yas2520 in (3,4) then do;
FLAG_pvmb=1;
flagck_mb=1;
if yas2760=1 & yas2762>=0 then pvmb=yas2762;
else if yas2760=2 & yas2764L>=0 & yas2764U>=0 then do;
if yas2764U>=yas2764L then pvmb=(yas2764L+yas2764U)/2;
else pvmb=-3;
end;
if yas2760 not in (1,2) or yas2762 in (-1,-2) then do;
if 1<=yas2766<=7 then FLAG_pvmb=2;
if yas2766=1 then pvmb=12500;
else if yas2766=2 then pvmb=37500;
else if yas2766=3 then pvmb=75000;
else if yas2766=4 then pvmb=175000;
else if yas2766=5 then pvmb=375000;
else if yas2766=6 then pvmb=750000;
else if yas2766=7 then pvmb=1000001;
end;
end;
if yas2520=-1 or yas2764L=-1 or yas2764U=-1 or yas2766=-1 then pvmb=-1;
if yas2520=-2 or yas2764L=-2 or yas2764U=-2 or yas2766=-2 then pvmb=-2;
if yas2520=-3 or yas2764L=-3 or yas2764U=-3 or yas2766=-3 or yas2762=-3 then pvmb=-3;

if flag_pvmb=1 then do;
housing_type=3;
house_value=pvmb;
end;

******* this is the end of mobile home. ********;


******************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a mobile home site, ***;
*** its present value - pvst. ***;
******************************************************************************;

pvst=-4;
if yas2520 in (5,6) then do;
FLAG_pvst=1;
flagck_st=1;
if yas3010=1 & yas3012>=0 then pvst=yas3012;
else if yas3010=2 & yas3014L>=0 & yas3014U>=0 then do;
if yas3014U>=yas3014L then pvst=(yas3014L+yas3014U)/2;
else pvst=-3;
end;
if yas3010 not in (1,2) or yas3012 in (-1,-2) then do;
if 1<=yas3016<=7 then FLAG_pvst=2;
if yas3016=1 then pvst=12500;
else if yas3016=2 then pvst=57500;
else if yas3016=3 then pvst=75000;
else if yas3016=4 then pvst=175000;
else if yas3016=5 then pvst=575000;
else if yas3016=6 then pvst=750000;
else if yas3016=7 then pvst=1000001;
end;
end;
if yas2520=-1 or yas3014L=-1 or yas3014U=-1 or yas3016=-1 then pvst=-1;
if yas2520=-2 or yas3014L=-2 or yas3014U=-2 or yas3016=-2 then pvst=-2;
if yas2520=-3 or yas3014L=-3 or yas3014U=-3 or yas3016=-3 or yas3012=-3 then pvst=-3;

if flag_pvst=1 then do;
housing_type=5;
house_value=pvst;
end;

if yas2520=8 then do;
housing_type=6;
house_value=-4;
end;
******** this is the end of mobile home site. ********;

*******************************************************;
*** THIS IS THE END OF MOBILE HOME & ITS SITE PART. ***;
*******************************************************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own an apartment, ***;
*** its present value - pvapt. ***;
*************************************************************************;

pvapt=-4;
if yas3310 in (1,2) then do;
FLAG_pvapt=1;
flagck_apt=1;
if yas3380=1 & yas3382>=0 then pvapt=yas3382;
else if yas3380=2 & yas3384L>=0 & yas3384U>=0 then do;
if yas3384U>=yas3384L then pvapt=(yas3384L+yas3384U)/2;
else pvapt=-3;
end;
if yas3380 not in (1,2) or yas3382 in (-1,-2) then do;
if 1<=yas3386<=7 then FLAG_pvapt=2;
if yas3386=1 then pvapt=500;
else if yas3386=2 then pvapt=1750;
else if yas3386=3 then pvapt=3750;
else if yas3386=4 then pvapt=7500;
else if yas3386=5 then pvapt=17500;
else if yas3386=6 then pvapt=37500;
else if yas3386=7 then pvapt=50001;
end;
end;
if yas3310=-1 or yas3384L=-1 or yas3384U=-1 or yas3386=-1 then pvapt=-1;
if yas3310=-2 or yas3384L=-2 or yas3384U=-2 or yas3386=-2 then pvapt=-2;
if yas3310=-3 or yas3384L=-3 or yas3384U=-3 or yas3386=-3 or yas3382=-3 then pvapt=-3;

if yas3310 in (1,2) and yas3340=0 then housing_type=1;
else if yas3310 in (1,2) and yas3340=1 and yas3360=1 then housing_type=8;
else if yas3310 in (1,2) and yas3340=1 and yas3360=2 then housing_type=7;

if flag_pvapt=1 then house_value=pvapt;

if yas3310=4 then do;
housing_type=6;
house_value=-4;
end;

/*************************************************************/

/*************************************************************/

********** this is the end of apartment part. *********************;


*************************************************************************;
*** If R alone or R and R's partner/spouse jointly own a business, ***;
*** partnership or professional practice, its present value - pvbuss. ***;
*************************************************************************;

pvbuss=-4;
if yas4010 in (1,2) then do;
FLAG_pvbuss=1;
if yas4030A=1 then do;
if yas4032A>=0 then pvbuss=yas4032A;
else if yas4032A in (-1,-2) then do;
if yas4034AU>=yas4034AL and yas4034AU>=0 and yas4034AL>=0 then pvbuss=(yas4034AL+yas4034AU)/2;
else pvbuss=-3;
end;
if yas4034AU in (-1,-2) then do;
if 1<=yas4036A<=7 then flag_pvbuss=2;
if yas4036A=1 then pvbuss=12500;
else if yas4036A=2 then pvbuss=37500;
else if yas4036A=3 then pvbuss=75000;
else if yas4036A=4 then pvbuss=175000;
else if yas4036A=5 then pvbuss=375000;
else if yas4036A=6 then pvbuss=750000;
else if yas4036A=7 then pvbuss=1000001;
end;
if pvbuss>0 then pvbuss=-1*pvbuss;
end;
else if yas4030A=2 then do;
if yas4032>=0 then pvbuss=yas4032;
if yas4032 in (-1,-2) then do;
if 1<=yas4036<=7 then FLAG_pvbuss=2;
if yas4036=1 then pvbuss=12500;
else if yas4036=2 then pvbuss=37500;
else if yas4036=3 then pvbuss=75000;
else if yas4036=4 then pvbuss=175000;
else if yas4036=5 then pvbuss=375000;
else if yas4036=6 then pvbuss=750000;
else if yas4036=7 then pvbuss=1000001;
end;
end;
else if yas4030A=3 then pvbuss=0;
end;


if yas4010=-1 or yas4034AL=-1 or yas4034AU=-1 or yas4036A=-1 or yas4036=-1 then pvbuss=-1;
if yas4010=-2 or yas4034AL=-2 or yas4034AU=-2 or yas4036A=-2 or yas4036=-2 then pvbuss=-2;
if yas4010=-3 or yas4034AL=-3 or yas4034AU=-3 or yas4036A=-3 or yas4036=-3 or yas4032=-3 then pvbuss=-3;

********* this is the end of business part. *****************;


*******************************************************************;
*** If R alone or R and R's partner/spouse jointly own a second ***;
*** real estate, its present value - othreal. ***;
*******************************************************************;

othreal=-4;
if yas4140 in (1,2) then do;
FLAG_othreal=1;
if yas4160=1 & yas4162>=0 then othreal=yas4162;
else if yas4160=2 & yas4164U>=0 & yas4164L>=0 then do;
if yas4164U>=yas4164L then othreal=(yas4164L+yas4164U)/2;
else othreal=-3;
end;
if yas4160 not in (1,2) or yas4162 in (-1,-2) then do;
if 1<=yas4166<=7 then FLAG_othreal=2;
if yas4166=1 then othreal=12500;
else if yas4166=2 then othreal=37500;
else if yas4166=3 then othreal=75000;
else if yas4166=4 then othreal=175000;
else if yas4166=5 then othreal=375000;
else if yas4166=6 then othreal=750000;
else if yas4166=7 then othreal=1000001;
end;
end;
if yas4140=-1 or yas4164L=-1 or yas4164U=-1 or yas4166=-1 then othreal=-1;
if yas4140=-2 or yas4164L=-2 or yas4164U=-2 or yas4166=-2 then othreal=-2;
if yas4140=-3 or yas4164L=-3 or yas4164U=-3 or yas4166=-3 or yas4162=-3 then othreal=-3;

**************** this is the end of other real estate. ********************;


******************************************************************************;
*** If R or R's partner/spouse have retirement plans or pensions - retdsav ***;
******************************************************************************;

retdsav=-4;
if yas4270 in (1,2,3) then do;
FLAG_retdsav=1;
if yas4290=1 & yas4292>=0 then retdsav=yas4292;
else if yas4290=2 & yas4294U>=0 & yas4294L>=0 then do;
if yas4292>=yas4294L then retdsav=(yas4294L+yas4294U)/2;
else retdsav=-3;
end;
if yas4290 not in (1,2) or yas4292 in (-1,-2) then do;
if 1<=yas4296<=7 then FLAG_retdsav=2;
if yas4296=1 then retdsav=2500;
else if yas4296=2 then retdsav=7500;
else if yas4296=3 then retdsav=17500;
else if yas4296=4 then retdsav=37500;
else if yas4296=5 then retdsav=75000;
else if yas4296=6 then retdsav=175000;
else if yas4296=7 then retdsav=250001;
end;
end;
if yas4270=-1 or yas4294L=-1 or yas4294U=-1 or yas4296=-1 then retdsav=-1;
if yas4270=-2 or yas4294L=-2 or yas4294U=-2 or yas4296=-2 then retdsav=-2;
if yas4270=-3 or yas4294L=-3 or yas4294U=-3 or yas4296=-3 or yas4292=-3 then retdsav=-3;

******** this is the end of retirement plans. ****************;


*******************************************************************;
*** If R or R's partner/spouse have banksav in saving accounts, ***;
*** money market, funds,trusts, - banksav. ***;
*******************************************************************;

banksav=-4;
if yas4400 in (1,2,3) then do;
FLAG_banksav=1;
if yas4420=1 & yas4422>=0 then banksav=yas4422;
else if yas4420=2 & yas4424U>=0 & yas4424L>=0 then do;
if yas4424U>=yas4424L then banksav=(yas4424L+yas4424U)/2;
else banksav=-3;
end;
if yas4420 not in (1,2) or yas4422 in (-1,-2) then do;
if 1<=yas4426<=7 then FLAG_banksav=2;
if yas4426=1 then banksav=500;
else if yas4426=2 then banksav=1750;
else if yas4426=3 then banksav=3750;
else if yas4426=4 then banksav=7500;
else if yas4426=5 then banksav=17500;
else if yas4426=6 then banksav=37500;
else if yas4426=7 then banksav=50001;
end;
end;
if yas4400=-1 or yas4424L=-1 or yas4424U=-2 or yas4426=-1 then banksav=-1;
if yas4400=-2 or yas4424L=-2 or yas4424U=-2 or yas4426=-2 then banksav=-2;
if yas4400=-3 or yas4424L=-3 or yas4424U=-3 or yas4426=-3 or yas4422=-3 then banksav=-3;

************* this is the end of bank savings. ****************;


******************************************************************************;
*** If R or R's partner/spouse have other banksav in bonds or cds - bonds. ***;
******************************************************************************;

bonds=-4;
if yas4530 in (1,2,3) then do;
FLAG_bonds=1;
if yas4550=1 & yas4552>=0 then bonds=yas4552;
else if yas4550=2 & yas4554U>=0 & yas4554L>=0 then do;
if yas4554U>=yas4554L then bonds=(yas4554L+yas4554U)/2;
else bonds=-3;
end;
if yas4550 not in (1,2) or yas4552 in (-1,-2) then do;
if 1<=yas4556<=7 then FLAG_bonds=2;
if yas4556=1 then bonds=500;
else if yas4556=2 then bonds=1750;
else if yas4556=3 then bonds=3750;
else if yas4556=4 then bonds=7500;
else if yas4556=5 then bonds=17500;
else if yas4556=6 then bonds=37500;
else if yas4556=7 then bonds=50001;
end;
end;
if yas4530=-1 or yas4554L=-1 or yas4554U=-1 or yas4556=-1 then bonds=-1;
if yas4530=-2 or yas4554L=-2 or yas4554U=-2 or yas4556=-2 then bonds=-2;
if yas4530=-3 or yas4554L=-3 or yas4554U=-3 or yas4556=-3 or yas4552=-3 then bonds=-3;

***************** this is the end of bonds. **********************;


*** If the respondent or his/her partner/spouse have stocks, mutual funds - stocks;

stocks=-4;
if yas4660 in (1,2,3) then do;
FLAG_stocks=1;
if yas4680=1 & yas4682>=0 then stocks=yas4682;
else if yas4680=2 & yas4684L>=0 & yas4684U>=0 then do;
if yas4684U>=yas4684L then stocks=(yas4684L+yas4684U)/2;
else stocks=-3;
end;
if yas4680 not in (1,2) or yas4682 in (-1,-2) then do;
if 1<=yas4686<=7 then FLAG_stocks=2;
if yas4686=1 then stocks=500;
else if yas4686=2 then stocks=1750;
else if yas4686=3 then stocks=3750;
else if yas4686=4 then stocks=7500;
else if yas4686=5 then stocks=17500;
else if yas4686=6 then stocks=37500;
else if yas4686=7 then stocks=50001;
end;
end;
if yas4660=-1 or yas4684L=-1 or yas4684U=-1 or yas4686=-1 then stocks=-1;
if yas4660=-2 or yas4684L=-2 or yas4684U=-2 or yas4686=-2 then stocks=-2;
if yas4660=-3 or yas4684L=-3 or yas4684U=-3 or yas4686=-3 or yas4682=-3 then stocks=-3;

****************** this is the end of stocks. ***********************;


************************************************************************;
*** If the respondent alone or respondent and his/her partner/spouse ***;
*** jointly own vehicles, their present value - pvcars. ***;
************************************************************************;

pvcars=-4;
if yas4790 in (1,2,3) then do;
FLAG_pvcars=1;
if yas4810=1 & yas4812>=0 then pvcars=yas4812;
else if yas4810=2 & yas4814L>=0 & yas4814U>=0 then do;
if yas4814U>=yas4814L then pvcars=(yas4814L+yas4814U)/2;
else pvcars=-3;
end;
if yas4810 not in (1,2) or yas4812 in (-1,-2) then do;
if 1<=yas4816<=7 then FLAG_pvcars=2;
if yas4816=1 then pvcars=2500;
else if yas4816=2 then pvcars=7500;
else if yas4816=3 then pvcars=17500;
else if yas4816=4 then pvcars=37500;
else if yas4816=5 then pvcars=75000;
else if yas4816=6 then pvcars=175000;
else if yas4816=7 then pvcars=250001;
end;
end;
if yas4790=-1 or yas4814L=-1 or yas4814U=-1 or yas4816=-1 then pvcars=-1;
if yas4790=-2 or yas4814L=-2 or yas4814U=-2 or yas4816=-2 then pvcars=-2;
if yas4790=-3 or yas4814L=-3 or yas4814U=-3 or yas4816=-3 or yas4812=-3 then pvcars=-3;

***************** this is the end of vehicles part. **********************;


*********************************************************************;
*** If R alone or R and R's partner/spouse jointly own furniture, ***;
*** its present value - pvfurn. ***;
*********************************************************************;

pvfurn=-4;
if yas4870>-4 then FLAG_pvfurn=1;
if yas4870=1 then pvfurn=2500;
else if yas4870=2 then pvfurn=7500;
else if yas4870=3 then pvfurn=17500;
else if yas4870=4 then pvfurn=37500;
else if yas4870=5 then pvfurn=75000;
else if yas4870=6 then pvfurn=175000;
else if yas4870=7 then pvfurn=250001;
else if yas4870=-1 then pvfurn=-1;
else if yas4870=-2 then pvfurn=-2;
else if yas4870=-3 then pvfurn=-3;

************** this is the end of furniture part. *****************;


***************************************************************************;
*** If R alone or R and R's partner/spouse jointly own other assets not ***;
*** mentioned before - othsav. ********************************************;
***************************************************************************;

othsav=-4;
if yas4880 in (1,2,3) then do;
FLAG_othsav=1;
if yas4900=1 & yas4902>=0 then othsav=yas4902;
else if yas4900=2 & yas4904L>=0 & yas4904U>=0 then do;
if yas4904U>=yas4904L then othsav=(yas4904L+yas4904U)/2;
else othsav=-3;
end;
if yas4900 not in (1,2) or yas4902 in (-1,-2) then do;
if 1<=yas4906<=7 then FLAG_othsav=2;
if yas4906=1 then othsav=2500;
else if yas4906=2 then othsav=7500;
else if yas4906=3 then othsav=17500;
else if yas4906=4 then othsav=37500;
else if yas4906=5 then othsav=75000;
else if yas4906=6 then othsav=175000;
else if yas4906=7 then othsav=250001;
end;
end;
if yas4880=-1 or yas4904L=-1 or yas4904U=-1 or yas4906=-1 then othsav=-1;
if yas4880=-2 or yas4904L=-2 or yas4904U=-2 or yas4906=-2 then othsav=-2;
if yas4880=-3 or yas4904L=-3 or yas4904U=-3 or yas4906=-3 or yas4902=-3 then othsav=-3;

************** this is the end of other savings. **********************;



*************************************************************************;
**** THIS IS THE END OF ASSETS. ****;
**** THE FOLLOWING IS LIABILITIES. ****;
*************************************************************************;



***********************************************************************;
*** If there is mortgage or land contract on the aforementioned land ***;
*** or property - mortgag. ***;
***********************************************************************;

mortgag=-4;
if yas3740 in (1,2) then do;
FLAG_mortgag=1;
if yas3750=1 & yas3752>=0 then mortgag=yas3752;
else if yas3750=2 & yas3754L>=0 & yas3754U>=0 then do;
if yas3754U>=yas3754L then mortgag=(yas3754L+yas3754U)/2;
else mortgag=-3;
end;
if yas3750 not in (1,2) or yas3752 in (-1,-2) then do;
if 1<=yas3756<=7 then FLAG_mortgag=2;
if yas3756=1 then mortgag=500;
else if yas3756=2 then mortgag=1750;
else if yas3756=3 then mortgag=3750;
else if yas3756=4 then mortgag=7500;
else if yas3756=5 then mortgag=17500;
else if yas3756=6 then mortgag=37500;
else if yas3756=7 then mortgag=50001;
end;
end;
if yas3740=-1 or yas3754L=-1 or yas3754U=-1 or yas3756=-1 then mortgag=-1;
if yas3740=-2 or yas3754L=-2 or yas3754U=-2 or yas3756=-2 then mortgag=-2;
if yas3740=-3 or yas3754L=-3 or yas3754U=-3 or yas3756=-3 or yas3752>=0 then mortgag=-3;

***************** this is the end of mortgage part. *******************;


*****************************************************************;
*** If R or R's partner/spouse has unpaid loans from Round 7 ***;
*** (yas3840=1 & yas3850=1) or still owes loans taken SDLI on ***;
*** house (yas3860=1) then total amount owed - resdebt. ***;
*****************************************************************;

resdebt=-4;
if (yas3840=1 & yas3850=1) or yas3860=1 then do;
FLAG_resdebt=1;
if yas3880=1 & yas3882>=0 then resdebt=yas3882;
else if yas3880=2 & yas3884U>=0 & yas3884L>=0 then do;
if yas3884U>=yas3884L then resdebt=(yas3884L+yas3884U)/2;
else resdebt=-3;
end;
if yas3880 not in (1,2) or yas3882 in (-1,-2) then do;
if 1<=yas3886<=7 then FLAG_resdebt=2;
if yas3886=1 then resdebt=500;
else if yas3886=2 then resdebt=1750;
else if yas3886=3 then resdebt=3750;
else if yas3886=4 then resdebt=7500;
else if yas3886=5 then resdebt=17500;
else if yas3886=6 then resdebt=37500;
else if yas3886=7 then resdebt=50001;
end;
end;
if yas3850=-1 or yas3860=-1 or yas3884L=-1 or yas3884U=-1 or yas3886=-1
then resdebt=-1;
if yas3850=-2 or yas3860=-2 or yas3884L=-2 or yas3884U=-2 or yas3886=-2
then resdebt=-2;
if yas3850=-3 or yas3860=-3 or yas3884L=-3 or yas3884U=-3 or yas3886=-3 or yas3882=-3
then resdebt=-3;

************** this is the end of resdebt. ****************;


***************************************************************;
*** If the respondent or his/her partner/spouse have second ***;
*** mortgages - othmort. ***;
***************************************************************;

othmort=-4;
if yas3910=1 then do;
FLAG_othmort=1;
if yas3920=1 & yas3922>=0 then othmort=yas3922;
else if yas3920=2 & yas3924U>=0 & yas3924L>=0 then do;
if yas3924U>=yas3924L then othmort=(yas3924L+yas3924U)/2;
else othmort=-3;
end;
if yas3920 not in (1,2) or yas3922 in (-1,-2) then do;
if 1<=yas3926<=7 then FLAG_othmort=2;
if yas3926=1 then othmort=500;
else if yas3926=2 then othmort=1750;
else if yas3926=3 then othmort=3750;
else if yas3926=4 then othmort=7500;
else if yas3926=5 then othmort=17500;
else if yas3926=6 then othmort=37500;
else if yas3926=7 then othmort=50001;
end;
end;
if yas3910=-1 or yas3924L=-1 or yas3924U=-1 or yas3926=-1 then othmort=-1;
if yas3910=-2 or yas3924L=-2 or yas3924U=-2 or yas3926=-2 then othmort=-2;
if yas3910=-3 or yas3924L=-3 or yas3924U=-3 or yas3926=-3 or yas3922=-3 then othmort=-3;

********** this is the end of other mortgage. ******************;


*******************************************************************************;
*** If R or R's partner/spouse still owe money on these vehicles - cardebt. ***;
*******************************************************************************;

cardebt=-4;
if yas4840>-4 then FLAG_cardebt=1;
if yas4840=1 & yas4842>=0 then cardebt=yas4842;
else if yas4840=2 & yas4844L>=0 & yas4844U>=0 then do;
if yas4844U>=yas4844L then cardebt=(yas4844L+yas4844U)/2;
else cardebt=-3;
end;
if yas4840 not in (1,2) or yas4842 in (-1,-2) then do;
if 1<=yas4846<=7 then FLAG_cardebt=2;
if yas4846=1 then cardebt=2500;
else if yas4846=2 then cardebt=7500;
else if yas4846=3 then cardebt=17500;
else if yas4846=4 then cardebt=37500;
else if yas4846=5 then cardebt=75000;
else if yas4846=6 then cardebt=175000;
else if yas4846=7 then cardebt=250001;
end;
if yas4790=-1 or yas4844L=-1 or yas4844U=-1 or yas4846=-1 then cardebt=-1;
if yas4790=-2 or yas4844L=-2 or yas4844U=-2 or yas4846=-2 then cardebt=-2;
if yas4790=-3 or yas4844L=-3 or yas4844U=-3 or yas4846=-3 or yas4842=-3 then cardebt=-3;

**************** this is the end of car debt. **********************;


*************************famedudebt**********************************;

famedudebt=-4;
if yas5011=1 then do;
flag_famedudebt=1;
if yas5011A=1 & yas5012>=0 then famedudebt=yas5012;
else if yas5011A=2 then do;
if yas5013L>=0 & yas5013U>=yas5013L then famedudebt=(yas5013L+yas5013U)/2;
else famedudebt=-3;
end;
if yas5011A not in (1,2) or yas5012 in (-1,-2) then do;
if 1<=yas5014<=7 then flag_famedudebt=2;
if yas5014=1 then famedudebt=500;
else if yas5014=2 then famedudebt=1750;
else if yas5014=3 then famedudebt=3750;
else if yas5014=4 then famedudebt=7500;
else if yas5014=5 then famedudebt=17500;
else if yas5014=6 then famedudebt=37500;
else if yas5014=7 then famedudebt=50001;
end;
end;

if yas5011=-1 or yas5011A=-1 or yas5013U=-1 or yas5013L=-1 or yas5014=-1 then famedudebt=-1;
if yas5011=-2 or yas5011A=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2 then famedudebt=-2;
if yas5011=-3 or yas5011A=-3 or yas5013U=-3 or yas5013L=-3 or yas5014=-3 or yas5012=-3 then famedudebt=-3;

*******************************************************************************************;

********************** Government loan *****************************;

govdebt=-4;
if yas5015=1 then do;
flag_govdebt=-4;
if yas5015A=1 & yas5016>=0 then govdebt=yas5016;
else if yas5015A=2 then do;
if yas5017L>=0 & yas5017U>=yas5017L then govdebt=(yas5017L+yas5017U)/2;
else govdebt=-3;
end;
if yas5015A not in (1,2) or yas5016 in (-1,-2) then do;
if 1<=yas5018<=7 then flag_govdebt=2;
if yas5018=1 then govdebt=500;
else if yas5018=2 then govdebt=1750;
else if yas5018=3 then govdebt=3750;
else if yas5018=4 then govdebt=7500;
else if yas5018=5 then govdebt=17500;
else if yas5018=6 then govdebt=37500;
else if yas5018=7 then govdebt=50001;
end;
end;

if yas5015=-1 or yas5015A=-1 or yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
if yas5015=-2 or yas5015A=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
if yas5015=-3 or yas5015A=-3 or yas5017U=-3 or yas5017L=-3 or yas5018=-3 or yas5016=-3 then govdebt=-3;


************ this is the end of govdebt. ********************************;


****************************************************************************;
*** If the respondent still owes loans to family or relatives, ***;
*** means has been loaned SDLI - famdebt. ***;
****************************************************************************;

array famdebt (20) famdebt01-famdebt20;
array yas5080 (20) yas508001-yas508020;
array yas5082 (20) yas508201-yas508220;
array yas5084L (20) yas5084L01-yas5084L20;
array yas5084U (20) yas5084U01-yas5084U20;
array yas5086 (20) yas508601-yas508620;
array yas5170 (20) yas517001-yas517020;
array yas5172 (20) yas517201-yas517220;
array yas5174L (20) yas5174L01-yas5174L20;
array yas5174U (20) yas5174U01-yas5174U20;
array yas5176 (20) yas517601-yas517620;

array yas5074 (20) yas507401-yas507420;
array yas5164 (20) yas516401-yas516420;

do i=1 to dim(famdebt);
famdebt(i)=-4;
** R was NOT loaned money from family/friends at last assets interview **;
** but has been loaned SDLI. **;
if yas5040=1 then do;
FLAG_famdebt=1.1;
if yas5080(i)=1 & yas5082(i)>=0 then famdebt(i)=yas5082(i);
else if yas5080(i)=2 & yas5084L(i)>=0 & yas5084U(i)>=0
then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
if yas5080(i) not in (1,2) or yas5082(i) in (-1,-2) then do;
if 1<=yas5086(i)<=7 then FLAG_famdebt=2.1;
if yas5086(i)=1 then famdebt(i)=500;
else if yas5086(i)=2 then famdebt(i)=1750;
else if yas5086(i)=3 then famdebt(i)=3750;
else if yas5086(i)=4 then famdebt(i)=7500;
else if yas5086(i)=5 then famdebt(i)=17500;
else if yas5086(i)=6 then famdebt(i)=37500;
else if yas5086(i)=7 then famdebt(i)=50001;
end;
end;
if yas5040=-1 or yas5074(i)=-1 or yas5086(i)=-1 or yas5084L(i)=-1 or yas5084U(i)=-1
then famdebt(i)=-1;
if yas5040=-2 or yas5074(i)=-2 or yas5086(i)=-2 or yas5084L(i)=-2 or yas5084U(i)=-2
then famdebt(i)=-2;
if yas5040=-3 or yas5074(i)=-3 or yas5086(i)=-3 or yas5084L(i)=-3 or yas5084U(i)=-3 or yas5082(i)=-3
then famdebt(i)=-3;

** R was loaned money from family/friends at last assets interview **;
** and has also been loaned SDLI. **;
if yas5130=1 then do;
FLAG_famdebt=1.2;
if yas5170(i)=1 & yas5172(i)>=0 then famdebt(i)=yas5172(i);
else if yas5170(i)=2 & yas5174L(i)>=0 & yas5174U(i)>=0
then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
if yas5170(i) not in (1,2) or yas5172(i) in (-1,-2) then do;
if 1<=yas5176(i)<=7 then FLAG_famdebt=2.2;
if yas5176(i)=1 then famdebt(i)=500;
else if yas5176(i)=2 then famdebt(i)=1750;
else if yas5176(i)=3 then famdebt(i)=3750;
else if yas5176(i)=4 then famdebt(i)=7500;
else if yas5176(i)=5 then famdebt(i)=17500;
else if yas5176(i)=6 then famdebt(i)=37500;
else if yas5176(i)=7 then famdebt(i)=50001;
end;
end;
if yas5130=-1 or yas5164(i)=-1 or yas5176(i)=-1 or yas5174L(i)=-1 or yas5174U(i)=-1
then famdebt(i)=-1;
if yas5130=-2 or yas5164(i)=-2 or yas5176(i)=-2 or yas5174L(i)=-2 or yas5174U(i)=-2
then famdebt(i)=-2;
if yas5130=-3 or yas5164(i)=-3 or yas5176(i)=-3 or yas5174L(i)=-3 or yas5174U(i)=-3 or yas5172(i)=-3
then famdebt(i)=-3;
end;

***************** this is the end of family debts. ************************;



****************************************************************;
*** If R or R's partner/spouse jointly have other debts from ***;
*** loans, credit cards, etc. ***;
****************************************************************;

othdebt=-4;
if yas5210=1 then do;
FLAG_othdebt=1;
if yas5220=1 & yas5222>=0 then othdebt=yas5222;
else if yas5220=2 & yas5224L>=0 & yas5224U>=0 then do;
if yas5224U>=yas5224L then othdebt=(yas5224L+yas5224U)/2;
else othdebt=-3;
end;
if yas5220 not in (1,2) or yas5222 in (-1,-2) then do;
if 1<=yas5226<=7 then FLAG_othdebt=2;
if yas5226=1 then othdebt=500;
else if yas5226=2 then othdebt=1750;
else if yas5226=3 then othdebt=3750;
else if yas5226=4 then othdebt=7500;
else if yas5226=5 then othdebt=17500;
else if yas5226=6 then othdebt=37500;
else if yas5226=7 then othdebt=50001;
end;
end;
if yas5210=-1 or yas5224L=-1 or yas5224U=-1 or yas5226=-1 then othdebt=-1;
if yas5210=-2 or yas5224L=-2 or yas5224U=-2 or yas5226=-2 then othdebt=-2;
if yas5210=-3 or yas5224L=-3 or yas5224U=-3 or yas5226=-3 or yas5222=-3 then othdebt=-3;

***************** this is the end of other debts. **************************;

****************************************************************************;
**** THIS IS THE END OF LIABILITIES. ****;
****************************************************************************;




******************************************************************;
***** THIS IS THE END OF DATA CLEANING. *****;
***** THE FOLLOWING IS CALCULATION. *****;
******************************************************************;


************************************************************************;
*** Compute the respondent's household net worth (hhworthY). ***;
*** hhworthY=assets-liabilities. YAST-1400 is the question ***;
*** determining whether respondents are asked the assets question. ***;
************************************************************************;

array varsasst (*) pvranch pvmbst pvmb pvst pvapt pvbuss othreal /*items of assets */
retdsav banksav bonds stocks pvcars pvfurn othsav;
array varsliab (*) mortgag resdebt othmort cardebt famedudebt govdebt othdebt
famdebt01-famdebt20; /*items of liabilities */

array flgsasst (*) flag_pvranch flag_pvmbst flag_pvmb flag_pvst flag_pvapt
flag_pvbuss flag_othreal flag_retdsav flag_banksav flag_bonds
flag_stocks flag_pvcars flag_pvfurn flag_othsav;
array flgsliab (*) flag_mortgag flag_resdebt flag_othmort flag_cardebt flag_famedudebt flag_govdebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

array ahousedebt (*) mortgag resdebt othmort;
array afinance (*) retdsav banksav bonds stocks othsav;
array anonfinance (*) othreal pvcars pvfurn pvbuss;
array adebt (*) cardebt famedudebt govdebt othdebt famdebt01-famdebt20;


array flgshsdt(*) flag_mortgag flag_resdebt flag_othmort;

array flgsfin(*) flag_retdsav flag_banksav flag_bonds flag_stocks flags_othsav;

array flgsnonfin(*) flag_othreal flag_pvcars flag_pvfurn flag_pvbuss;

array flgsdebt(*) flag_cardebt flag_famedudebt flag_govdebt flag_othdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt
flag_famdebt flag_famdebt flag_famdebt flag_famdebt flag_famdebt;

if yas1400=-4 then do;
hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;
end;

if (yas1400=0 or yas1400=1) then do;

hhworthY=0; assets=0; liabilities=0; housedebt=0;finance=0;nonfinance=0;debt=0;

do i=1 to dim(varsasst);
if varsasst(i)not in (-1,-2,-3,-4) then assets=assets+varsasst(i);
if varsasst(i) in (-1,-2,-3) then flgsasst(i)=-3;
end;

do i=1 to dim(varsliab);
if varsliab(i)>=0 then liabilities=liabilities+varsliab(i);
if varsliab(i) in (-1,-2,-3) then flgsliab(i)=-3;
end;

hhworthY=assets-liabilities;

do i=1 to dim(ahousedebt);
if ahousedebt(i)>=0 then housedebt=housedebt+ahousedebt(i);
if ahousedebt(i) in (-1,-2,-3) then flgshsdt(i)=-3;
end;
do i=1 to dim(afinance);
if afinance(i)>=0 then finance=finance+afinance(i);
if afinance(i) in (-1, -2, -3) then flgsfin(i)=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)not in (-1,-2,-3,-4) then nonfinance=nonfinance+anonfinance(i);
if anonfinance(i) in (-1, -2, -3) then flgsnonfin(i)=-3;
end;
do i=1 to dim(adebt);
if adebt(i)>=0 then debt=debt+adebt(i);
if adebt(i) in (-1, -2, -3) then flgsdebt(i)=-3;
end;

end;




*** Code hhworthY as a valid skip for those who were not asked the assets questions;
if yas1400=-4 then do;
hhworthY=-4;
vskpHHY=1;
end;

*** Code hhworthY as an invalid skip for those who did not give valid responses;
do i=1 to dim(varsasst);
if varsasst(i)=-1 then do;
hhworthY=-1;
assets=-1;
invskpHHY=1;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-1 then do;
hhworthY=-1;
invskpHHY=1;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-2 then do;
hhworthY=-2;
assets=-2;
invskpHHY=2;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-2 then do;
hhworthY=-2;
invskpHHY=2;
end;
end;

do i=1 to dim(varsasst);
if varsasst(i)=-3 then do;
hhworthY=-3;
assets=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(varsliab);
if varsliab(i)=-3 then do;
hhworthY=-3;
invskpHHY=3;
end;
end;
do i=1 to dim(ahousedebt);
if ahousedebt(i)=-1 then housedebt=-1;
else if ahousedebt(i)=-2 then housedebt=-2;
else if ahousedebt(i)=-3 then housedebt=-3;
end;
do i=1 to dim(afinance);
if afinance(i)=-1 then finance=-1;
else if afinance(i)=-2 then finance=-2;
else if afinance(i)=-3 then finance=-3;
end;
do i=1 to dim(anonfinance);
if anonfinance(i)=-1 then nonfinance=-1;
else if anonfinance(i)=-2 then nonfinance=-2;
else if anonfinance(i)=-3 then nonfinance=-3;
end;
do i=1 to dim(adebt);
if adebt(i)=-1 then debt=-1;
else if adebt(i)=-2 then debt=-2;
else if adebt(i)=-3 then debt=-3;
end;

hhworthY=round(hhworthY,1);
assets=round(assets,1);
housedebt=round(housedebt,1);
house_value=round(house_value,1);
finance=round(finance,1);
nonfinance=round(nonfinance,1);
debt=round(debt,1);

************* Change all the -1s, -2s to -3s. ***************;

array finalv(*) hhworthY assets housedebt house_value finance nonfinance debt;
do i=1 to dim(finalv);
if finalv(i) in (-1,-2) then finalv(i)=-3;
end;

run;

******* End of the program. *********************;

Return to top


Variable Merge
 

/******************************************************************************************
** **
** Created variables: **
** ----------------------------------------------------- **
** Name in program Name on CD **
** --------------- ------------------- **
** top_hhworthY CV_HH_NET_WORTH_20 **
** top_house_value CV_HOUSE_VALUE_20 **
** top_housedebt CV_HOUSE_DEBT_20 **
** housing_type CV_HOUSE_TYPE_20 **
** top_finance CV_FINANCE_20 **
** top_nonfinance CV_NONFINANCE_20 **
** top_debt CV_DEBT_20 **
** round CV_ASSET_RND_20 **
** ----------------------------------------------------- **
** **
** **
** **
** Age_20_variabls intend to record the respondents' assets value when he was 20 years old. **
** In fact, age_20_variables come from the rounds that respondents FIRST hit assets section **
** AFTER their 20s. **
** **
** This project include several programs: **
** 1. rXage_20.sas, where X is 3,4,5,6,7,8 standing for different rounds; **
** 2. merge20.sas. **
** rXage_20.sas creates age_20_variables on the rounds when respondents were older than 20; **
** merge20.sas merges the variables together. **
** **
** **
** **
** This program merges age_20_variables from r3 to r8 to generate the final age_20_variables **
** and top-code the top 2%. **
** **
** The procedure to create the age-20_variables is: **
** 1, generate the variables for respondents who hit assets section and older than 20 for **
** each round; **
** 2, merge the variables of each round together by replacing the "newer" round with "older" **
** round; **
** 3, merge those who were never interviewed after their 20's; **
** 4, set -5 to those who were not interviewed in round 8. **
** **
** The value of the age_20_variables are top-coded if and only if it is above the top 2%, **
** which means the we top-code the variables seperately. **
** **
***********************************************************************************************/


libname r3 "C:\My Documents\NLSY97\Round8\Data\r3";
libname r4 "C:\My Documents\NLSY97\Round8\Data\r4";
libname r5 "C:\My Documents\NLSY97\Round8\Data\r5";
libname r6 "C:\My Documents\NLSY97\Round8\Data\r6";
libname r7 "C:\My Documents\NLSY97\Round8\Data\r7";
libname r8 "C:\My Documents\NLSY97\Round8\Data\r8";
libname age20 "C:\My Documents\NLSY97\Round8\Data";


data age20.r3;
set r3.age20r3;
keep
pubid
round
lround
curdate_y
age
yas1400
hhworthY
house_value
housedebt
housing_type
debt
assets
finance
nonfinance
pvranch
pvmbst
pvmb
pvst
pvapt
pvbuss
othreal
retdsav
banksav
bonds
stocks
pvcars
pvfurn
othsav
mortgag
resdebt
othmort
cardebt
othdebt
famdebt01-famdebt20;
;


data age20.r4;
set r4.age20r4;
keep
pubid
round
lround
curdate_y
age
yas1400
hhworthY
house_value
housedebt
housing_type
debt
assets
finance
nonfinance
pvranch
pvmbst
pvmb
pvst
pvapt
pvbuss
othreal
retdsav
banksav
bonds
stocks
pvcars
pvfurn
othsav
mortgag
resdebt
othmort
cardebt
othdebt
famdebt01-famdebt20;
;

data age20.r5;
set r5.age20r5;
keep
pubid
round
lround
curdate_y
age
yas1400
hhworthY
house_value
housedebt
housing_type
debt
assets
finance
nonfinance
pvranch
pvmbst
pvmb
pvst
pvapt
pvbuss
othreal
retdsav
banksav
bonds
stocks
pvcars
pvfurn
othsav
mortgag
resdebt
othmort
cardebt
othdebt
famdebt01-famdebt20;
;

data age20.r6;
set r6.age20r6;
keep
pubid
round
lround
curdate_y
age
yas1400
hhworthY
house_value
housedebt
housing_type
debt
assets
finance
nonfinance
pvranch
pvmbst
pvmb
pvst
pvapt
pvbuss
othreal
retdsav
banksav
bonds
stocks
pvcars
pvfurn
othsav
mortgag
resdebt
othmort
cardebt
othdebt
famdebt01-famdebt20;
;

data age20.r7;
set r7.age20r7;
keep
pubid
round
lround
curdate_y
age
yas1400
hhworthY
house_value
housedebt
housing_type
debt
assets
finance
nonfinance
pvranch
pvmbst
pvmb
pvst
pvapt
pvbuss
othreal
retdsav
banksav
bonds
stocks
pvcars
pvfurn
othsav
mortgag
resdebt
othmort
cardebt
famedudebt
govdebt
othdebt
famdebt01-famdebt20;
;

data age20.r8;
set r8.age20r8;
keep
pubid
round
lround
curdate_y
age
yas1400
hhworthY
house_value
housedebt
housing_type
debt
assets
finance
nonfinance
pvranch
pvmbst
pvmb
pvst
pvapt
pvbuss
othreal
retdsav
banksav
bonds
stocks
pvcars
pvfurn
othsav
mortgag
resdebt
othmort
cardebt
famedudebt
govdebt
othdebt
famdebt01-famdebt20;
;

run;
/*data age20.r8_19;
set r8.r8_19;
run;
*/



%macro line;
%do i=3 %to 8;
proc sort data=age20.r&i;
by pubid;
run;
%end;
%mend;

%line;

data age20.merged20;
set age20.r8;
run;

%macro meg20;
%do i=7 %to 3 %by -1;
data age20.merged20;
update age20.merged20 age20.r&i;
by pubid;
run;
%end;
%mend;

%meg20;



data age20.merged20;
set age20.merged20;
if yas1400 in (0,1) then interviewed=1;
else interviewed=yas1400;
drop yas1400;
run;


data age20.nonintview;
set age20.r8nonint;
array finalv(*) round lround curdate_y age interviewed hhworthY house_value housedebt housing_type debt assets finance
nonfinance pvranch pvmbst pvmb pvst pvapt pvbuss othreal retdsav banksav bonds stocks pvcars pvfurn
othsav mortgag resdebt othmort cardebt famedudebt govdebt othdebt famdebt01-famdebt20;
do i=1 to dim(finalv);
finalv(i)=-5;
end;
drop i int;
run;

proc sort data=age20.nonintview;
by pubid;
run;

proc sort data=age20.merged20;
by pubid;
run;

data age20.merged20;
merge age20.merged20 age20.nonintview;
by pubid;
run;



/********************************/
/*** hand edit (1) *****/
/********************************/

/* There are 17 cases lack of asset value. What happened was: The Rs were 20 when interviewed, but */
/* the computer let them valid skip asset section due to the problem with the date function. */
/* Case 1231601 in R4 also had the same problem, but he was not interviewed in R8, so 1231601 was */
/* set to -5. */


data age20.merged20;
set age20.merged20;
array finalv(*) round lround curdate_y age interviewed hhworthY house_value housedebt housing_type
debt assets finance nonfinance pvranch pvmbst pvmb pvst pvapt pvbuss othreal retdsav banksav
bonds stocks pvcars pvfurn othsav mortgag resdebt othmort cardebt famedudebt govdebt othdebt
famdebt01-famdebt20;
if pubid in
(87
334
873
1546
3964
4786
5096
5104
5141
5318
5576
5714
6152
6219
7244
6319) then do;
do i=1 to dim(finalv);
finalv(i)=-3;
end;
end;
/*The value of hhworthY of case 1795381 happened to be -5 which is taken by
CHRR as non-interview. So, we set it as -6. */
if pubid=7680 then hhworthY=-6;
drop i;
run;

/********************************/
/*** hand edit (2) *****/
/********************************/

/* There are 18 cases whose house_value should be -3 instead of -4. Because when they gave -2s */
/* to the value of house, they were wrongly allowed to validly skip the questions of giving the */
/* range of the house value by the computer. So, their house_value are wrongly set to be -4s. */

data age20.merged20;
set age20.merged20;
if pubid in
(1419
1561
1925
1942
2867
3937
4718
4857
5789
5806
5999
6073
6692
6964
8079
8096
8418
8445 ) then do;
house_value=-3;
hhworthY=-3;
end;
run;


/*********End of merge. ***************************/
 


Return to top Return to Table of Contents