********************************** To create an uniform heading for every data file ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ***The new files are copied on the 'C:\1 Barbados\data' folder and ****into a second folder "C:\1 Barbados\analisys". The second folder save is done with the entire folder adress to have ***a working copy for the analysis. To change this directory, the original "CD" comand is not enough and a copy and replace is n ***necessary for the 12 longfiles name . ***FOR EXAMPLE, THE FIRST CASE IS IN LINES 176 (FILE SAVED IN THE default "C:\1 Barbados\data" FOLDER) AND ***LINE 181 (FILE SAVED IN THE "C:\1 Barbados\analisys\" FOLDER) ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ***To have the HHID in numeric format nd date of enterview cd 'C:\1 Barbados\data' . GET FILE='RT001_Public.sav' keep = hhid vis1_dat mth . string visit1_day (A12) . COMPUTE visit1_day =substring(vis1_dat,1,2). execute . string visit1_month (A12) . COMPUTE visit1_month =substring(vis1_dat,4,2). execute . string visit1_year (A12) . COMPUTE visit1_year =substring(vis1_dat,7,4). execute . alter type visit1_day visit1_month visit1_year (f8.0). ***4 household reported interview year above 2017, recode them to 2016 or 2017 acording tovalue in variable mth IF (visit1_year > 2017 and mth = 1) visit1_year=2017. IF (visit1_year > 2017 and mth > 1) visit1_year=2016. EXECUTE. ***29 households reported years > 1000 and < 2016, recode them to 2016 or 2017 acording tovalue in variable mth IF (visit1_year > 1000 and visit1_year < 2016 and mth = 1) visit1_year=2017. IF (visit1_year > 1000 and visit1_year < 2016 and mth > 1) visit1_year=2016. EXECUTE. ***4 cases with misiting date recode to 1 . RECODE visit1_day visit1_month visit1_year (SYSMIS=1). EXECUTE. *** 87 households with visiting year = 1, this include the 4 cases missing date and 83 cases with date = 01-01-0001. ***recode them to 2016 or 2017 acording tovalue in variable mth using the day 15 for all of them . DO IF (visit1_year = 1). RECODE visit1_day (1=15). END IF. EXECUTE. ***The mth code is the same as the month of the interview IF (visit1_year =1 ) visit1_month = mth . execute . ***Use the year in variable mth . IF (visit1_year = 1 and mth = 1) visit1_year=2017. IF (visit1_year = 1 and mth > 1) visit1_year=2016. EXECUTE. COMPUTE hhid_n=NUMBER(hhid,f8.0). EXECUTE. format hhid_n (F8.0) . SORT CASES BY hhid_n(A). IF (hhid_n = LAG(hhid_n)) doble=1. EXECUTE. FREQUENCIES VARIABLES=doble /ORDER=ANALYSIS. ***ok, only 0s ... it is an unique identifier. SORT CASES BY hhid(A). VARIABLE label hhid_n "Household Identifier in numeric format" . DELETE VARIABLES doble vis1_dat. SAVE OUTFILE='borrar.sav' /COMPRESSED. ***************************, GET FILE='borrar.sav'. *********************************************************************************, ***To have the HHsize a. GET FILE='RT002_Public.sav'. FREQUENCIES VARIABLES=q1_02 /ORDER=ANALYSIS. ***only 2 "Visitor" and 2 "Domestic servant" were included as household members. We will assume that for some reason ***they are considered household members . IF (q1_02 = 1) HHH_gender=q1_03. VARIABLE LABELS hhh_gender 'Household head gender'. EXECUTE. SORT CASES BY hhid(A) q1_02(A). AGGREGATE /OUTFILE=* /BREAK=hhid /hhh_gender 'Household head gender'=FIRST(HHH_gender) /hh_size=N. variable label hh_size "# of household members" . value labels hhh_gender 1"Male" 2"Female". MATCH FILES /TABLE=* /FILE='borrar.sav' /BY hhid. EXECUTE. ***25,508 households. SAVE OUTFILE='00 hhid string y numerico.sav' /COMPRESSED. ***************************, GET FILE='00 hhid string y numerico.sav'. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** To create an uniform heading for every data file ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. GET FILE='RT001_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='01 household_cover_12a_13.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\01 household_cover_12a_13.sav' /COMPRESSED. ***************************, GET FILE='01 household_cover_12a_13.sav'. FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT002_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='02 person_01-10.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\02 person_01-10.sav' /COMPRESSED. ***************************. GET FILE='02 person_01-10.sav'. FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT011_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='03 p_expenses_11.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\03 p_expenses_11.sav' /COMPRESSED. ***************************. GET FILE='03 p_expenses_11.sav'. FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT121_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='04 crop_12b.sav' /COMPRESSED. ****. SAVE OUTFILE='C:\1 Barbados\analisys\04 crop_12b.sav' /COMPRESSED. ***************************. GET FILE='04 crop_12b.sav'. FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT122_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='05 animal_12c.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\05 animal_12c.sav' /COMPRESSED. ***************************. GET FILE='05 animal_12c.sav'. FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT123_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='06 milk_12d.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\06 milk_12d.sav' /COMPRESSED. ***************************. GET FILE='06 milk_12d.sav' . FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT124_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='07 fish_12e.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\07 fish_12e.sav' /COMPRESSED. ***************************. GET FILE='07 fish_12e.sav' . FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT125_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='08 ag_input_12f.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\08 ag_input_12f.sav' /COMPRESSED. ***************************. GET FILE='08 ag_input_12f.sav' . FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT126_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='09 ag_asset_12g.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\09 ag_asset_12g.sav' /COMPRESSED. ***************************. GET FILE='09 ag_asset_12g.sav' . FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT140_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='10 food_14a.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\10 food_14a.sav' /COMPRESSED. ***************************. GET FILE='10 food_14a.sav' . FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT141_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='11 non_food_14b-d.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\11 non_food_14b-d.sav' /COMPRESSED. ***************************. GET FILE='11 non_food_14b-d.sav' . FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. *********************************************************************************, GET FILE='RT003_Public.sav'. SORT CASES BY hhid(A). MATCH FILES /FILE=* /TABLE='00 hhid string y numerico.sav' /BY hhid. EXECUTE. rename variable (HHID = hhid_string) (hhid_n=hhid) . SAVE OUTFILE='12 emigration_15.sav' /COMPRESSED. ***. SAVE OUTFILE='C:\1 Barbados\analisys\12 emigration_15.sav' /COMPRESSED. ***************************. GET FILE='12 emigration_15.sav'. FREQUENCIES VARIABLES=hhid /FORMAT=NOTABLE /STATISTICS=MEAN /ORDER=ANALYSIS. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. ********************************** Add the changes into the files and save them in two places ************************************************************. erase file "borrar.sav" .