***variable level xxx (scale) (ordinal) (nominal ) . ********************************************* Personal Expenditures ********************************************* . cd 'C:\1 Barbados\analisys' . GET FILE='03 p_expenses_11.sav'. ***recode from missig yo YES (expended in last 7 days) IF PURCHASE VALUE WAS REPORTED . DO IF (q11_02 > 0 and q11_02 < 9999). RECODE q11_01y (SYSMIS=1). END IF. EXECUTE. ***100 % YES . **15 cases reported YES, to expenditures, but value was 0. Probably the answer was no, eliminate those cases . RECODE q11_02 (0=1) (ELSE=0) INTO borrar. EXECUTE. FILTER OFF. USE ALL. SELECT IF (borrar = 0). EXECUTE. FILTER OFF. USE ALL. EXECUTE. ************************************************** START create specific data vairables ***************************************. *Crear variable para transformar en per cápita. Si no se ocupa, poner 1 . COMPUTE PC= hh_size . EXECUTE. ***define varible to be examined (Make sure cases with no service o item had a missing value) . COMPUTE var= q11_02/pc . EXECUTE. ***ID missing cases . COMPUTE lack_data = 0 . IF (q11_01y = 1 & MISSING(var)) lack_data=1. EXECUTE. ***Create variable for level of analysis. If none use a "1" . COMPUTE level= perexpco . EXECUTE. ***************************************************** END create specific data vairables ***************************************. ***Estandar deviationa from the mean . AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=level /var_mean=MEAN(var) /var_sd=SD(var). COMPUTE sd_mean=ABS(RND( (var - var_mean)/var_sd,0.1)). EXECUTE. SORT CASES BY sd_mean(D). EXAMINE VARIABLES=sd_mean /PLOT BOXPLOT /COMPARE GROUPS /STATISTICS DESCRIPTIVES /CINTERVAL 95 /MISSING LISTWISE /NOTOTAL. COMPUTE var_ex = 0. EXECUTE. FREQUENCIES VARIABLES=lack_data /ORDER=ANALYSIS. ************************************************** START cut-off point for replacement ******************************. ***Cases replaced: 20 + 21 missing: 41 . IF (sd_mean > 8.1 or lack_data=1) var_ex=var_mean * pc. Compute var = var * pc . IF (sd_mean > 8.1 or lack_data=1) var=var_mean * pc . EXECUTE. ************************************************** END cut-off point for replacement ******************************. RECODE var_ex var (SYSMIS=0). EXECUTE. FREQUENCIES VARIABLES= var var_ex /ORDER=ANALYSIS. ************************************************** START define new varaibles and save file ******************************. IF (perexpco >= 3901 and perexpco <= 3915) food_away=var *365/7/12. variable label food_away "Food away from home/month/household" . IF (perexpco >= 3901 and perexpco <= 3915) food_away_ex=var_ex *365/7/12. variable label food_away_ex "Estimated food away from home/month/household" . execute . IF (perexpco >= 4001 and perexpco <= 4005) other_tobacco=var *365/7/12. variable label other_tobacco "Tobacco /month/household" . IF (perexpco >= 4001 and perexpco <= 4005) other_tobacco_ex=var_ex *365/7/12. variable label other_tobacco_ex "Estimated tobacco /month/household" . execute . IF ( (perexpco >= 4101 and perexpco <= 4004 and perexpco ~= 4202 ) or ( perexpco >= 4304 and perexpco <= 4305) or ( perexpco >= 4401 and perexpco <= 4402) ) comunication=var *365/7/12. variable label comunication "Transport and comunications/month/household" . IF ( (perexpco >= 4101 and perexpco <= 4004 and perexpco ~= 4202 ) or ( perexpco >= 4304 and perexpco <= 4305) or ( perexpco >= 4401 and perexpco <= 4402) ) comunication_ex=var_ex *365/7/12. variable label comunication_ex "Estimated transport and comunications/month/household" . execute . IF (perexpco = 4202) school_bus=var *365/7/12. variable label school_bus "School_bus /month/household" . IF (perexpco = 4202) school_bus_ex=var_ex *365/7/12. variable label school_bus_ex "Estimated school_bus /month/household" . execute . IF (( perexpco >= 4301 and perexpco <= 4303) or ( perexpco >= 4306 and perexpco <= 4309) ) entertaiment=var *365/7/12. variable label entertaiment "Recreation, entertaiment/month/household" . IF (( perexpco >= 4301 and perexpco <= 4303) or ( perexpco >= 4306 and perexpco <= 4309) ) entertaiment_ex=var *365/7/12. variable label entertaiment_ex "Estimated recreation, entertaiment/month/household" . execute . DELETE VARIABLES lack_data level var_mean var_sd sd_mean var var_ex . RECODE food_away food_away_ex other_tobacco other_tobacco_ex comunication comunication_ex school_bus school_bus_ex entertaiment entertaiment_ex (SYSMIS=0). EXECUTE. *DELETE VARIABLES filter_$ . *DELETE VARIABLES . SORT CASES BY hhid(A) perexpco (A). SAVE OUTFILE='b0 personal_exp.sav' /COMPRESSED. ********************. GET FILE='b0 personal_exp.sav'. ************************************************** END define new varaibles and save file ******************************. ***Create one file withone entry per household per variables. GET FILE='b0 personal_exp.sav'. AGGREGATE /OUTFILE=* /BREAK=hhid hhid_string hh_size psu weight stratum /food_away =SUM(food_away) /food_away_ex =SUM(food_away_ex) /other_tobacco =SUM(other_tobacco) /other_tobacco_ex =SUM(other_tobacco_ex) /comunication =SUM(comunication) /comunication_ex =SUM(comunication_ex) /school_bus =SUM(school_bus) /school_bus_ex =SUM(school_bus_ex) /entertaiment =SUM(entertaiment) /entertaiment_ex =SUM(entertaiment_ex). variable label food_away "Food away from home/month/household" . variable label food_away_ex "Estimated food away from home/month/household" . variable label other_tobacco "Tobacco /month/household" . variable label other_tobacco_ex "Estimated tobacco /month/household" . variable label comunication "Transport and comunications/month/household" . variable label comunication_ex "Estimated transport and comunications/month/household" . variable label school_bus "School_bus /month/household" . variable label school_bus_ex "Estimated school_bus /month/household" . variable label entertaiment "Recreation, entertaiment/month/household" . variable label entertaiment_ex "Estimated recreation, entertaiment/month/household" . SORT CASES BY hhid(A) . SAVE OUTFILE='b1 personal_exp.sav' /COMPRESSED. ********************. GET FILE='b1 personal_exp.sav'.