***variable level xxx (scale) (ordinal) (nominal ) . ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. cd 'C:\1 Barbados\analisys' . GET FILE='10 food_14a.sav' . COMPUTE foodcode_new = foodcode . EXECUTE . COMPUTE quantity_month=quantity * anncoeff / 12. COMPUTE amount_month=amount * anncoeff / 12. EXECUTE. COMPUTE quantity_month_original=quantity * anncoeff / 12. COMPUTE amount_month_original=amount * anncoeff / 12. EXECUTE. ***Add data property from file "d food file with new code.sav" . It has to be done by hand in *** data --> Copy data properties -->select file "C:\1 Barbados\analisys\d food file with new code.sav" . variable level foodcode foodcode_new (nominal ) . formats amount (comma8.2) . ***78,329 casess . ***30 cases without value and 0 quantity, eliminate them . COMPUTE delete=0. IF (quantity = 0 AND MISSING(amount)) delete=1. EXECUTE. FILTER OFF. USE ALL. SELECT IF (delete = 0). EXECUTE. ***78,299 CASES COMPUTE all_missing=1. IF (quantity > 0 or amount > 0) all_missing=0. EXECUTE. ***5,054 cases do not have quantity nor value. Leave them until the end and estimate the average value and quantity ***3,691 cases have AMMOUNT but do not have QUANTITY. ***3,627 cases have QUANTITY bot do not hava AMMOUNT . ***5,054 CASES DO NOT HAVE EITHER .. ***Cattle feed (5 cases) and poultry feed (9 cases), should not be hers FILTER OFF. USE ALL. SELECT IF (foodcode ~= 816 and foodcode ~= 817). EXECUTE. ****78,285 lines left . SAVE OUTFILE='delete1.sav' /COMPRESSED. ***********. GET FILE='delete1.sav'. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. GET FILE='delete1.sav'. USE ALL. COMPUTE filter_$=(all_missing = 0 and quantity_month > 0). FILTER BY filter_$. EXECUTE. FREQUENCIES VARIABLES=quantity_month /FORMAT=NOTABLE /ORDER=ANALYSIS. ***Because the number of observations is too low, some products will be recode into similar product with similar average values . *Rice in bulk to rice other animal oil to other vegetable oil grapefruit to oranges Soursops to other fruits fresh Pasion fruit to other fruits fresh Corn fresh to canned corn Egg plant to other vevetables fresh Other vegetables frozen to Other vevetablesprepared/preseved Other species to Other Pizza to other Coffee roasted to coffee instant Sparkling wine to wine Wiskey to Other spirits Gin to other spirits Other fermented to beer Others 2 to others 1 Others 3 to others 1 Others 4 to others 1 Others 5 to others 1 Others 6 to others 1 Others 7 to others 1 Others 8 to others 1 Others 9 to others 1 RECODE foodcode_new ( 116 = 104) ( 508 = 507) ( 606 = 601) ( 618 = 610) ( 621 = 610) ( 724 = 710) ( 726 = 727) ( 728 = 729) ( 806 = 9001) ( 813 = 9001) ( 815 = 9001) ( 910 = 909) ( 1003 = 1002) ( 1005 = 1007) ( 1006 = 1007) ( 1008 = 1001) ( 1009 = 915) ( 9002 = 9001) ( 9003 = 9001) ( 9004 = 9001) ( 9005 = 9001) ( 9006 = 9001) ( 9007 = 9001) ( 9008 = 9001) ( 9009 = 9001) . EXECUTE. FREQUENCIES VARIABLES=foodcode_new /ORDER=ANALYSIS. ***Minimum frequency = 50 observations . ************************************************* 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= quantity_month/pc . EXECUTE. ***ID missing cases . COMPUTE lack_data = 0 . IF ( MISSING(var)) lack_data=1. EXECUTE. ***Create variable for level of analysis. If none use a "1" . COMPUTE level= foodcode_new . 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). ***TO RUN THE SAME ANALYSIS WITHOUT THE BIGGEST OUTLIERS . ***86 CASES . compute super_out = 0 . IF (sd_mean > 10 ) super_out = 1 . EXECUTE . DO IF (super_out = 1). RECODE quantity_month (ELSE=SYSMIS). END IF. EXECUTE. COMPUTE var= quantity_month/pc . EXECUTE. DELETE VARIABLES var_mean var_sd sd_mean . ***AND WE RUN THE LAST PAR AGAIN WITHOUT THE BIGGEST OUTLIERS . ***************************************************** 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). ****The examination and determination has to be done for each variable type EXAMINE VARIABLES=sd_mean /PLOT BOXPLOT /COMPARE GROUPS /STATISTICS DESCRIPTIVES /CINTERVAL 95 /MISSING LISTWISE /NOTOTAL. FREQUENCIES VARIABLES=lack_data sd_mean /ORDER=ANALYSIS. ************************************************** START cut-off point for replacement ******************************. ***Cases replaced: 86 SUPER + 48 NEW : 134 . . IF (sd_mean >= 10 OR super_out = 1) var_ex=var_mean * pc. Compute var = var * pc . IF (sd_mean >= 10 OR super_out = 1) var=var_mean * pc . EXECUTE. ************************************************** END cut-off point for replacement ******************************. DO IF (quantity > 0). RECODE var var_ex (SYSMIS=0). END IF. EXECUTE. FREQUENCIES VARIABLES= var var_ex /ORDER=ANALYSIS. ************************************************** START define new varaibles and save file ******************************. compute quantity_month = var . compute quantity_month_ex = var_ex . EXECUTE . FILTER OFF. USE ALL. EXECUTE. delete variables var lack_data level super_out var_mean var_sd sd_mean var_ex PC . SAVE OUTFILE='delete2.sav' /COMPRESSED. ***********. GET FILE='delete2.sav'. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** FIRST: Review quantities for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. GET FILE='delete2.sav'. ****78,285 lines left . USE ALL. COMPUTE filter_$=(all_missing = 0 and amount_month > 0). FILTER BY filter_$. EXECUTE. * Custom Tables. CTABLES /VLABELS VARIABLES=foodcode_new amount_month DISPLAY=DEFAULT /TABLE foodcode_new [C] BY amount_month [S][MEAN, COUNT F40.0, SUM, MEDIAN] /CATEGORIES VARIABLES=foodcode_new ORDER=A KEY=VALUE EMPTY=EXCLUDE. ***Only three products have values bellow 50 (see list). Since this products will have the quantity information for more housheholds ***(for a total > 50), we will work as it is . * 0619 Papayas 40 * 0620 Breadfruits 34 * 1007 Other spirits 46 ************************************************* 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= amount_month/pc . EXECUTE. ***ID missing cases . COMPUTE lack_data = 0 . IF ( MISSING(var)) lack_data=1. EXECUTE. ***Create variable for level of analysis. If none use a "1" . COMPUTE level= foodcode_new . 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). ***TO RUN THE SAME ANALYSIS WITHOUT THE BIGGEST OUTLIERS . ***70 CASES . compute super_out = 0 . IF (sd_mean >= 10 ) super_out = 1 . EXECUTE . DO IF (super_out = 1). RECODE amount_month (ELSE=SYSMIS). END IF. EXECUTE. COMPUTE var= amount_month/pc . EXECUTE. DELETE VARIABLES var_mean var_sd sd_mean . ***AND WE RUN THE LAST PAR AGAIN WITHOUT THE BIGGEST OUTLIERS . ***************************************************** 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). ****The examination and determination has to be done for each variable type EXAMINE VARIABLES=sd_mean /PLOT BOXPLOT /COMPARE GROUPS /STATISTICS DESCRIPTIVES /CINTERVAL 95 /MISSING LISTWISE /NOTOTAL. FREQUENCIES VARIABLES=lack_data sd_mean /ORDER=ANALYSIS. ************************************************** START cut-off point for replacement ******************************. ***Cases replaced: 70 SUPER + 158 NEW : 228 . . IF (sd_mean > 7 OR super_out = 1) var_ex=var_mean * pc. Compute var = var * pc . IF (sd_mean > 7 OR super_out = 1) var=var_mean * pc . EXECUTE. ************************************************** END cut-off point for replacement ******************************. DO IF (amount > 0). RECODE var var_ex (SYSMIS=0). END IF. EXECUTE. FREQUENCIES VARIABLES= var var_ex /ORDER=ANALYSIS. ************************************************** START define new varaibles and save file ******************************. compute amount_month = var . compute amount_month_ex = var_ex . EXECUTE . FILTER OFF. USE ALL. EXECUTE. delete variables var lack_data level super_out var_mean var_sd sd_mean var_ex PC . SAVE OUTFILE='delete3.sav' /COMPRESSED. ***********. GET FILE='delete3.sav'. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ***************************************** SECOND: Review VALUES for outliers . *******************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. GET FILE='delete3.sav'. ***Estimate average prices, quantities and values and their mean. COMPUTE quantity_month_pc = quantity_month/hh_size . COMPUTE amount_month_pc = amount_month/hh_size . execute . SORT CASES BY foodcode_new. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /PRESORTED /BREAK=foodcode_new /quantity_month_pc_mean=MEAN(quantity_month) /amount_month_pc_mean=MEAN(amount_month). ***4,264 cases without univ value correspond to "other products" For this cases, no calorc content is possible and ***no quantity is needed. ***For cases with value but no quantity, estimate quantity as: average PC quantiy * hh size. IF (MISSING(quantity_month) and quantity_month_pc_mean > 0 ) quantity_month_ex= quantity_month_pc_mean * hh_size. IF (MISSING(quantity_month) and quantity_month_pc_mean > 0 ) quantity_month = quantity_month_pc_mean * hh_size. EXECUTE. ***For cases with quantity but no value, estimate values as: average PC amount * hh size. IF (MISSING(amount_month) and amount_month_pc_mean > 0 ) amount_month_ex= amount_month_pc_mean * hh_size. IF (MISSING(amount_month) and amount_month_pc_mean > 0 ) amount_month = amount_month_pc_mean * hh_size. EXECUTE. ***Now all the observatins had all the information neccessasry. Remember that Others are not usefull for caloric content *** and their quantity is not usefull (they were recodedd into 9999) . SORT CASES BY hhid(A) foodcode(A) . SAVE OUTFILE='d0 food.sav' /COMPRESSED. ***********. GET FILE='d0 food.sav'. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. ************************************ **** THIRD: Estimate for missing values (no response) ************************************. GET FILE='d0 food.sav'. ***Estimate total quantities and values per househodls per product . AGGREGATE /OUTFILE=* /BREAK=hhid_string hhid weight psu stratum hhh_gender hh_size foodcode_new /quantity_month=SUM(quantity_month) /quantity_month_ex=SUM(quantity_month_ex) /amount_month=SUM(amount_month) /amount_month_ex=SUM(amount_month_ex). variable label quantity_month "Gr. or ml. of food per item/monthhousehold". variable label quantity_month_ex "Estimated gr. or ml. of food per item/monthhousehold". variable label amount_month "BB dollars in food per item/monthhousehold". variable label amount_month_ex "Estimated BB dollars in food per item/monthhousehold". SORT CASES BY hhid(A) foodcode_new(A) . SAVE OUTFILE='d1 food.sav' /COMPRESSED. ***********. GET FILE='d1 food.sav'. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. GET FILE='d1 food.sav'. AGGREGATE /OUTFILE= * /BREAK=hhid_string hhid weight psu stratum hhh_gender hh_size /food=SUM(amount_month) /food_ex=SUM(amount_month_ex). variable label food "BB dollars in food/monthhousehold". variable label food_ex "Estimated BB dollars in food monthhousehold". ***2,365 households , the same # of households reported in the original food file . SORT CASES BY hhid(A) . SAVE OUTFILE='d2 food.sav' /COMPRESSED. ***********. GET FILE='d2 food.sav'. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FORTH: Estimate total consumption value **************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ***To create the original list of products and to add the calorie informations. GET FILE='d1 food.sav'. ***Others are not useful . FILTER OFF. USE ALL. SELECT IF (foodcode_new ~= 9001). EXECUTE. ***Other fruits (fresh and frozen) or vegetables cannot be used . FILTER OFF. USE ALL. SELECT IF (foodcode_new ~= 610 and foodcode_new ~= 611 and foodcode_new ~= 727 ). EXECUTE. ***Foods for pets are not useful . FILTER OFF. USE ALL. SELECT IF (foodcode_new ~= 807). EXECUTE. ***Id the products with enoug expenditure . AGGREGATE /OUTFILE= * /BREAK= foodcode_new /food=SUM(amount_month) . variable label food "BB dollars in food/monthhousehold". ***Estimate total expenditure of all foods and brevages . AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK= /food_sum 'Total food value in the country'=SUM(food). ***Estimate % of total consumption COMPUTE per_food=100*food / food_sum. EXECUTE. ***Exclude items that represent less than 0.21% of total consumption . ***This are 27 items (seelist) and represent all together less than 3.5% of all consumption. *0622 Plums, 0113 Flour of wheat, 0805 White sugar, 0729 Other vegetables - prepared, pre, 0811 Natural honey, 0613 Lemons, 0803 Table Salt, 0913 Pineapple juice, 0712 Eschalots - fresh or chilled, 0809 Curry Powder, 0808 Black Pepper, 0216 Sausages - canned, 0306 Mackerels - prepared, preserved, 0717 Split Peas - dried, skinned, etc., 0405 Baby food milk, 0812 Other sauces and condiments, 0114 Meal (corn flour), 0504 Cooking butter, 0215 Pork - salted, 0607 Kiwis, 0912 Flavouring preparations fro. beverages, 0609 Raisins, FILTER OFF. USE ALL. SELECT IF (per_food >= 0.21). EXECUTE. * Several liquid convertions from mililiters to grams were found at : http://www.aqua-calc.com/calculate/food-volume-to-weight * Caloric contents and % of edible portion foound at * " Instituto de Nutrición de Centro América y Panamá (INCAP), Valor Nutritivo de los alimentos de Centroamérica,, * Guatemala, September, 1996" . ***the resulting file ws saved under: 'C:\1 Barbados\analisys\kilocalories.sav' SORT CASES BY foodcode_new(A). MATCH FILES /FILE=* /TABLE='C:\1 Barbados\analisys\kilocalories.sav' /BY foodcode_new. EXECUTE. *******************************************************************************************. ***To add the calorie information to all households. GET FILE='d1 food.sav'. SORT CASES BY foodcode_new(A). MATCH FILES /FILE=* /TABLE='C:\1 Barbados\analisys\kilocalories.sav' /BY foodcode_new. EXECUTE. *** 75,477 lines ***If no calorie information, do not use the product . FILTER OFF. USE ALL. SELECT IF (kcal_100gr >= 0). EXECUTE. *** 65,135 lines . (this excludes some products without calories, mostly groups of products (other ...), and a few animal *** food, and the products with very litle weight on the total food expenditure in thesample . **For each household, estimate total calories and total payment . ***The quantities firs trandfor to groups of 100 gr. or ml., then convert to edible portion, then, convert the mililiters into grams, an finally ***multiply by the calories content od edible portion of 100 grams. ***To change from montly to day, multiply by 12 and divide by 365 COMPUTE calories= ( (quantity_month /100) *edible * gr_in_ml * kcal_100gr) * 12 /365 . EXECUTE. compute amount_day = amount_month * 12 /365 . EXECUTE. ***For each houshold, estimate total value and total calories . AGGREGATE /OUTFILE=* /BREAK=hhid_string hhid weight psu stratum hh_size /value_day_sum=SUM(amount_day) /calories_day_sum=SUM(calories). SORT CASES BY hhid(A) . SAVE OUTFILE='kilocalories total and value for each hh.sav' /COMPRESSED. ******************. GET FILE='kilocalories total and value for each hh.sav'. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. ************************************ **** FIFTH: Estimate total quantities and calories *************************************. erase file 'delete1.sav'. erase file 'delete2.sav'. erase file 'delete3.sav'.