Over 20 Assets (Collapsed) - Appendix 5

Over 20 Assets (Collapsed) - Appendix 5

These variables were last created in round 12. The age 20 assets section was discontinued after that round as NLSY97 respondents had aged out of the section.

Variables Created

  • CVC_HH_NET_WORTH_20 (total net worth)
  • CVC_HOUSE_VALUE_20 (value of owned housing)
  • CVC_HOUSE_DEBT_20 (amount of housing debt)
  • CVC_HOUSE_TYPE_20 (type of housing owned)
  • CVC_ASSETS_FINANCIAL_20 (value of financial assets)
  • CVC_ASSETS_NONFINANCIAL_20 (value of non-financial assets, excluding housing)
  • CVC_ASSETS_DEBTS_20 (amount of debt, excluding housing)
  • CVC_ASSETS_RND_20 (round in which assets data were collected)

This program first creates a set of asset variables for those respondents who went through the age 20 assets section in round 12. The variables used in this section are listed in a separate file (due to the length of the list).

The program then combines the round 12 variables with the corresponding variables from rounds 3-11, creating a set of "collapsed" variables that includes age 20 assets information for all respondents, regardless of the round in which the data were collected. These variables are also included for all respondents, even if they were not interviewed in round 12. The individual round created variables are not available in the data set; only the collapsed variables are included.

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 Income, Assets & Program Participation section.

Variables Used

/**Variable Names in the Program       Variable Names on the Gator**/

 'yasNEW1'n              YAST-NEW1                    
 'yas025'n               YAST-025                     
 'yas060'n               YAST-060                     
 'yas070'n               YAST-070                     
 'yas105'n               YAST-105                     
 'yas200A'n              YAST-200A                    
 'yas210A'n              YAST-210A                    
 'yas500A'n              YAST-500A                    
 'yas510A'n              YAST-510A                    
 'yas520A'n              YAST-520A                   
 'yas1400'n              YAST-1400                   
 'yas1500'n              YAST-1500                   
 'yas3310'n              YAST-3310                   
 'yas3320'n              YAST-3320                   
 'yas3680'n              YAST-3680                   
 'yas3682'n              YAST-3682                   
 'yas3710'n              YAST-3710                   
 'yas3720'n              YAST-3720                   
 'yas3722'n              YAST-3722                   
 'yas3726'n              YAST-3726                   
 'yas4010'n              YAST-4010                   
 'yas4140'n              YAST-4140                   
 'yas4270'n              YAST-4270                   
 'yas4290'n              YAST-4290                   
 'yas4292'n              YAST-4292                   
 'yas4296'n              YAST-4296                   
 'yas4320'n              YAST-4320                   
 'yas4400'n              YAST-4400                   
 'yas4420'n              YAST-4420                   
 'yas4422'n              YAST-4422                   
 'yas4424L'n             YAST-4424_000001            
 'yas4424U'n             YAST-4424_000002            
 'yas4450'n              YAST-4450                   
 'yas4460'n              YAST-4460                   
 'yas4500'n              YAST-4500                   
 'yas4504L'n             YAST-4504_000001            
 'yas4504U'n             YAST-4504_000002            
 'yas4530'n              YAST-4530                   
 'yas4550'n              YAST-4550                   
 'yas4556'n              YAST-4556                   
 'yas4580'n              YAST-4580                   
 'yas4660'n              YAST-4660                   
 'yas4790'n              YAST-4790                   
 'yas4810'n              YAST-4810                   
 'yas4812'n              YAST-4812                   
 'yas4840'n              YAST-4840                   
 'yas4842'n              YAST-4842                   
 'yas4870'n              YAST-4870                   
 'yas4880'n              YAST-4880                   
 'yas5011'n              YAST-5011                   
 'yas5015'n              YAST-5015                   
 'yas5020'n              YAST-5020                   
 'yas5040'n              YAST-5040                   
 'yas5130'n              YAST-5130                   
 'yas514001'n            YAST-5140~000001            
 'yas514002'n            YAST-5140~000002            
 'yas514003'n            YAST-5140~000003            
 'yas514004'n            YAST-5140~000004            
 'yas514005'n            YAST-5140~000005            
 'yas514006'n            YAST-5140~000006            
 'yas514007'n            YAST-5140~000007            
 'yas514008'n            YAST-5140~000008            
 'yas514009'n            YAST-5140~000009            
 'yas514010'n            YAST-5140~000010            
 'yas514011'n            YAST-5140~000011            
 'yas514012'n            YAST-5140~000012            
 'yas514013'n            YAST-5140~000013            
 'yas514014'n            YAST-5140~000014            
 'yas514015'n            YAST-5140~000015            
 'yas514016'n            YAST-5140~000016            
 'yas514017'n            YAST-5140~000017            
 'yas514018'n            YAST-5140~000018            
 'yas514019'n            YAST-5140~000019            
 'yas514020'n            YAST-5140~000020            
 'yas5150'n              YAST-5150                   
 'yas5152'n              YAST-5152                  
 'yas515601'n            YAST-5156.01               
 'yas515602'n            YAST-5156.02               
 'yas515603'n            YAST-5156.03               
 'yas515604'n            YAST-5156.04               
 'yas515605'n            YAST-5156.05               
 'yas515606'n            YAST-5156.06               
 'yas515607'n            YAST-5156.07               
 'yas515608'n            YAST-5156.08               
 'yas515609'n            YAST-5156.09               
 'yas515610'n            YAST-5156.10               
 'yas515611'n            YAST-5156.11               
 'yas515612'n            YAST-5156.12               
 'yas515613'n            YAST-5156.13               
 'yas515614'n            YAST-5156.14               
 'yas515615'n            YAST-5156.15               
 'yas515616'n            YAST-5156.16               
 'yas515617'n            YAST-5156.17               
 'yas515618'n            YAST-5156.18               
 'yas515619'n            YAST-5156.19               
 'yas515620'n            YAST-5156.20               
 'yas516020'n            YAST-5160.20               
 'yas516420'n            YAST-5164.20               
 'yas517020'n            YAST-5170.20               
 'yas517220'n            YAST-5172.20               
 'yas5210'n              YAST-5210                  
 'yas5220'n              YAST-5220                  
 'yas5222'n              YAST-5222                  
 'yas5250'n              YAST-5250                  
 'yas5260'n              YAST-5260                  
 'yas5310'n              YAST-5310                  
 'pubid'n                pubid        

SAS Code for Variable Creation

    housing_type=-4;
    house_value=-4;

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

    /** If R alone or R and Rs 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;  
        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 Rs 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 Rs 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 in (1,2) 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 Rs 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 in (1,2) then
    do;
        housing_type=4;
        house_value=pvmbst;
    end;

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

    /************************************************************************
    *** If R alone or R and Rs 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 in (1,2) then do;
        housing_type=3;
        house_value=pvmb;
    end;

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

    /*****************************************************************************/
    /** If R alone or R and Rs 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 in (1,2) then
    do;
        housing_type=5;
        house_value=pvst;
    end;

    if yas2520 in (7,8,10) then
    do;
        housing_type=6;
        house_value=0;
    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 Rs 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 in (1,2) then house_value=pvapt;

    if yas3310 in (3, 4, 5) then
    do;
        housing_type=6;
        house_value=0;
        pvapt=0;
    end;

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

    /*************************************************************************/
    /*** If R alone or R and Rs 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;
            
        if yas4030A=2 then
        do;
            if  yas4032>=0 then pvbuss=yas4032;
        end;
        
        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;
        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 Rs 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 Rs 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 yas4294U>=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 Rs 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 Rs 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 Rs 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 Rs 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 or yas4900=-1               then othsav=-1;
    if yas4880=-2  or yas4904L=-2 or yas4904U=-2  or yas4906=-2 or yas4900=-2               then othsav=-2;
    if yas4880=-3  or yas4904L=-3 or yas4904U=-3  or yas4906=-3 or yas4900=-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 mortgag 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=-3 then mortgag=-3;

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

    /*****************************************************************/
    /*** If R or Rs 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 Rs 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 yas5013U=-1 or yas5013L=-1 or yas5014=-1   then famedudebt=-1;
    if yas5011=-2 or yas5013U=-2 or yas5013L=-2 or yas5014=-2   then famedudebt=-2;
    if yas5011=-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=1;
        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 yas5017U=-1 or yas5017L=-1 or yas5018=-1 then govdebt=-1;
    if yas5015=-2 or yas5017U=-2 or yas5017L=-2 or yas5018=-2 then govdebt=-2;
    if yas5015=-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
            do;
                if yas5084U(i)>=yas5084L(i) then famdebt(i)=(yas5084L(i)+yas5084U(i))/2;
                else famdebt(i)=-3;
            end;    
            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
            do;
                if  yas5174U(i)>= yas5174L(i) then famdebt(i)=(yas5174L(i)+yas5174U(i))/2;
                else famdebt(i)=-3;
            end;     
            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 Rs 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;
            

    hhworthY=-4; assets=-4; liabilities=-4; housedebt=-4;finance=-4;nonfinance=-4;debt=-4;

    if yas105 in (0,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,-5) 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) not in (-1,-2,-3,-4,-5)  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) not in (-1,-2,-3,-4,-5)  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) not in (-1,-2,-3,-4,-5)  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,-5)  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) not in (-1,-2,-3,-4,-5)  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 yas105=-4 then
    do;
        hhworthY=-4;
        vskpHHY=1;
    end;

    /** code house_value and housedebt to 0 if housing_type=6 **/

    /*** 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;


/* This part merging newly created r12 asset 20 variables with r12 variables

Name of r12 CVC to be created Name of Prev Rd CVC in the 'gator
Name of the current rd variable
hhworthY_20r12 CVC_HH_NET_WORTH_20_2007 hhworthY
house_value_20r12 CVC_HOUSE_VALUE_20_2007 house_value
housedebt_20r12 CVC_HOUSE_DEBT_20_2007 housedebt
housing_type_20r12 CVC_HOUSE_TYPE_20_2007 housing_type
finance_20r12 CVC_ASSETS_FINANCIAL_20_2007 finance
nonfinance_20r12 CVC_ASSETS_NONFINANCIAL_20_2007 nonfinance
debt_20r12 CVC_ASSETS_DEBTS_20_2007 debt
assetrd_20r12 CVC_ASSETS_RND_20_2007  assetrd
  YAST-105 (eligible case in 0,1) eligibility check

data updtprev;
    infile '/xxxxxxx',';
    input
    pubid CVC_HH_NET_WORTH_20_2007          CVC_HOUSE_VALUE_20_2007          CVC_HOUSE_DEBT_20_2007           
    CVC_HOUSE_TYPE_20_2007           CVC_ASSETS_FINANCIAL_20_2007     CVC_ASSETS_NONFINANCIAL_20_2007  
    CVC_ASSETS_DEBTS_20_2007         CVC_ASSETS_RND_20_2007            ;

proc sort data= updtprev ;
    by pubid;
run;

proc sort data= r12ast20.ast20;
    by pubid;
run;

data ast20cvc;
    merge r12ast20.ast20(keep=pubid yas070 yas105 hhworthY  house_value housedebt housing_type finance nonfinance debt)
    updtprev ;
    by pubid;
    
    array cvprevrd(8)
    CVC_HH_NET_WORTH_20_2007          CVC_HOUSE_VALUE_20_2007          CVC_HOUSE_DEBT_20_2007           
    CVC_HOUSE_TYPE_20_2007           CVC_ASSETS_FINANCIAL_20_2007     CVC_ASSETS_NONFINANCIAL_20_2007  
    CVC_ASSETS_DEBTS_20_2007         CVC_ASSETS_RND_20_2007     ;
    
    cvpreval=0;     
    do i=1 to 7;                                                                                           
        if cvprevrd(i) ~=-4 then cvpreval=1;
    end;

    array r12(7)
    hhworthY           house_value        housedebt          housing_type       finance
    nonfinance         debt          ;

    r12val=0;
    do i=1 to 7;                                                                                           
        if r12(i) not in (-4,-5,.) then r12val=1;
    end;

    array cvcr12(7)
    hhworthY_20r12       house_value_20r12    housedebt_20r12    housing_type_20r12       
    finance_20r12         nonfinance_20r12     debt_20r12    ;

    /* Initiate the R12 cvc variables to -4 */
    do i = 1 to dim(cvcr12);
        cvcr12(i)=-4;
    end;
    assetrd_20r12 =-4 ;

    

    /* Assign value by combination of last & current round values, also assign flag for checking.
    
    Flag=1   if both last & current rounds have none -4 values.
    Flag=2.1 if last round have only -4 values and has cvc_rnd assigned -3 (when shouldn't)
    Flag=2.2 if last round have only -4 values and has cvc_rnd assigned [3,11];
                use cvc_rnd for assetrd_20r12  ;
                use current round value variables for 7 other *_20r12 variables ;
    Flag=3.1 if last round have none -4 values but cvc_rnd is -4;
                use last round cvc value variables for 7 other *_20r12 variables ;    
                withheld assign rnd;
    Flag=3.2 if last round have none -4 values but cvc_rnd is -3;
                use last round cvc value variables for 7 other *_20r12 variables ;    
                assign rnd -3;
    Flag=4.1 if only -4 exits in both current & last round but cvc_rnd is [3,11];     
    Flag=4.2 if only -4 exits in both current & last round but cvc_rnd is -3;     
    Flag=5 if rnd is 1 or 2. (they shouldn't be.)     
    */
    

    if r12val=1 then do;
        if cvpreval=1 then do;
            flag=1;
        end;
        else if cvpreval=0 then do;
            if CVC_ASSETS_RND_20_2007=-4 then assetrd_20r12 = 12;  
            else if CVC_ASSETS_RND_20_2007=-3 then flag=2.1;
            else if CVC_ASSETS_RND_20_2007 in (3,4,5,6,7,8,9,10,11) then do;
                flag=2.2;
                assetrd_20r12 = CVC_ASSETS_RND_20_2007 ;
            end;    
            do i= 1 to 7 ;
                cvcr12(i)= r12(i) ;
            end ;            
        end;    
    end;
    else if r12val=0 then do;
        if cvpreval=1 then do;
            if CVC_ASSETS_RND_20_2007 in (3,4,5,6,7,8,9,10,11) then assetrd_20r12 = CVC_ASSETS_RND_20_2007 ;
            if CVC_ASSETS_RND_20_2007 =-4 then flag=3.1;
            if CVC_ASSETS_RND_20_2007 = -3 then do;
                assetrd_20r12=-3;            
                flag=3.2;
            end;    
            do i= 1 to 7 ;
                cvcr12(i)= cvprevrd(i) ;
            end ;            
        end;
        else if cvpreval=0 then do;
            if CVC_ASSETS_RND_20_2007 in (3,4,5,6,7,8,9,10,11) then flag=4.1 ;    
            else if CVC_ASSETS_RND_20_2007=-3 then flag=4.2;
            else if CVC_ASSETS_RND_20_2007=-4 then assetrd_20r12 = -4   ;
            do i= 1 to 7 ;
                cvcr12(i)= -4 ;
            end ;        
        end;    
    end;
    if CVC_ASSETS_RND_20_2007 in (1,2) then flag=5;
    
    /* Top coding. (There is no bottom coding.) */

    if hhworthY_20r12 ge 600000 then hhworthY_20r12=600000;
    if house_value_20r12 ge 425000 then house_value_20r12=425000;
    if housedebt_20r12 ge 325000 then housedebt_20r12=325000;
    if finance_20r12 ge 300000 then finance_20r12=300000;
    if nonfinance_20r12 ge 600000 then nonfinance_20r12=600000;
    if debt_20r12 ge 370000 then debt_20r12=370000;

    if htype=-4 & assetrd_20r12=12 then htype=6;
    if hval=-4 & assetrd_20r12=12 then hval=0;
endsas;