diff --git a/do_files/next_steps-data_discovery.do b/do_files/next_steps-data_discovery.do index 8d75f81..a55c6e2 100644 --- a/do_files/next_steps-data_discovery.do +++ b/do_files/next_steps-data_discovery.do @@ -14,29 +14,29 @@ log close * Create a Lookup Table Across All Datasets * ssc install filelist filelist, pattern("*.dta") -keep if !strmatch(dirname, "*UKDS*") +keep if inlist(dirname, "./safeguarded_eul", "./household_grids", "./activity_histories") // Keeps files in the three Next Steps subfolders tempfile file_list -save `file_list' +save "`file_list'" clear tempfile all_vars -save `all_vars', emptyok +save "`all_vars'", emptyok -use `file_list', clear +use "`file_list'", clear local n_files = _N forvalues i = 1/`n_files' { - use `file_list' in `i', clear + use "`file_list'" in `i', clear local filename = filename[1] local dirname = dirname[1] use "`dirname'/`filename'", clear describe *, replace gen dir = "`dirname'" gen file = "`filename'" - append using `all_vars' - save `all_vars', replace + append using "`all_vars'" + save "`all_vars'", replace } -use `all_vars', clear +use "`all_vars'", clear gen name_low = lower(name) gen varlab_low = lower(varlab) gen sweep = real(regexs(1)) if regexm(name_low, "^w([0-9])") // Extracts sweep from the variable name diff --git a/do_files/next_steps-household_grid.do b/do_files/next_steps-household_grid.do index 8e9f425..39b5462 100644 --- a/do_files/next_steps-household_grid.do +++ b/do_files/next_steps-household_grid.do @@ -11,7 +11,6 @@ bysort NSID: gen n = _N keep if n == 1 drop n keep NSID W1HhID W1EmpStat -save "temp_mothers.dta", replace * Mother's Employment tabulate W1EmpStat diff --git a/do_files/next_steps-merging_across_sweeps.do b/do_files/next_steps-merging_across_sweeps.do index 93a4ed5..4f49c84 100644 --- a/do_files/next_steps-merging_across_sweeps.do +++ b/do_files/next_steps-merging_across_sweeps.do @@ -11,7 +11,7 @@ save "temp_w4.dta", replace use "temp_w2.dta", clear merge 1:1 NSID using "temp_w4.dta" list NSID W2ghq12scr W4ghq12scr _merge in 1/10 -// Use `drop if _merge == x` or run `merge ..., keep(x)` to keep a specific type of match/non-match. +// Use `keep if _merge == x` or run `merge ..., keep(x)` to keep a specific type of match/non-match. * Appending Sweeps use "temp_w2.dta", clear diff --git a/do_files/next_steps-reshape_long_wide.do b/do_files/next_steps-reshape_long_wide.do index d0b9d27..251f994 100644 --- a/do_files/next_steps-reshape_long_wide.do +++ b/do_files/next_steps-reshape_long_wide.do @@ -12,7 +12,7 @@ sort NSID list in 1/10 * Reshape Raw Wide to Long -rename (W#HEIGHT W#WEIGHT) (HEIGHT# WEIGHT#) // reshape requires the sweep number to be at the end of the name +rename (W#HEIGHT W#WEIGHT) (HEIGHT# WEIGHT#) // Moves the sweep number to the end of the name, where reshape expects it by default reshape long HEIGHT WEIGHT, i(NSID) j(sweep) list in 1/10 @@ -27,8 +27,8 @@ global ages 14 15 16 17 18 19 20 25 32 rename (W#HEIGHT W#WEIGHT) (HEIGHT# WEIGHT#) reshape long HEIGHT WEIGHT, i(NSID) j(sweep) gen age = real(word("${ages}", sweep)) -gen height = HEIGHT if HEIGHT > 0 -gen weight = WEIGHT if WEIGHT > 0 +gen double height = HEIGHT if HEIGHT > 0 // double keeps the full precision of the raw values +gen double weight = WEIGHT if WEIGHT > 0 keep NSID age height weight list in 1/10