Project

General

Profile

Support #2066 » 2. 2066 (option2).log

 
----------------------------------------------------------------------------------
name: <unnamed>
log: D:\USF\issues\2066\2066 (option2).log
log type: text
opened on: 7 Mar 2024, 21:49:13

. /* Note: The data file produced will be at the individual level and cover all a
> ges, irrespective of the variables requested.
/ is not a valid command name
r(199);

.
. In this current version of the tool, it is not possible to select variables by
> wave - though you may edit the code below to do so. */
command In is unrecognized
r(199);

.
.
.
. /*******************************************************************************
> *********
/ is not a valid command name
r(199);

.
. * Sample Code for your request: 7a400d9a784848fd9e94ac517185bf40 *

.
. ********************************************************************************
> *********/

.
. clear all

.
. set more off

.
.
.
. // Replace "where" with the filepath of the working folder (where any temporary
> files created by this programme will be stored) eg: c:\ukhls\temp
/ is not a valid command name
r(199);

.
. cd "where"
unable to change to where
r(170);

.
.
.
. // Replace "where" with the folderpath where the data has been downloaded and un
> zipped eg: c:\ukhls_data\UKDA-6614-stata\stata\stata13_se\ukhls
/ is not a valid command name
r(199);

.
. global ukhls "where\UKDA-6614-stata\stata\stata13_se\ukhls"

.
.
.
. // Replace "where" with the filepath of the folder where you want to store the f
> inal dataset produced by this programme. eg: c:\ukhls\results
/ is not a valid command name
r(199);

.
. global outputpath "where"

.
.
.
. // The file produced by this programme will be named as below. If you want to ch
> ange the name do it here.
/ is not a valid command name
r(199);

.
. local outputfilename "UKHLS_wide_hij"

.
.
.
. // By default the data will be extracted from the waves whose letter prefixes ar
> e written below, and merged. If you want to a different selection of waves, make
> the change here
/ is not a valid command name
r(199);

.
. local allWaves = "h i j"

.
.
.
. // These variables from the indall files will be included. These include some ke
> y variables as determined by us PLUS any variables requested by you.
/ is not a valid command name
r(199);

.
. local indallvars "age_dv country ethn_dv gor_dv hhsize hidp mastat_dv nchild_dv
> pidp pno psnen01_lw psnen01_xw psnen91_lw psnen91_xw psnen99_lw psnen99_xw psnen
> ub_lw psnenub_xw psnenui_lw psnenui_xw psnenus_lw psnenus_xw psu racel_dv sex_dv
> strata urban_dv"

.
.
.
. // These variables from the indresp files will be included. These include some k
> ey variables as determined by us PLUS any variables requested by you.
/ is not a valid command name
r(199);

.
. local indvars "age_dv country ethn_dv gor_dv hhsize hhtype_dv hidp ind5mus_lw in
> d5mus_xw indbd91_lw indbdub_lw indin01_lw indin01_xw indin91_lw indin91_xw indin
> 99_lw indin99_xw indinub_lw indinub_xw indinui_lw indinui_xw indinus_lw indinus_
> xw indns91_lw indnsub_lw indpxub_lw indpxub_xw indpxui_lw indpxui_xw indpxus_lw
> indpxus_xw indscub_lw indscub_xw indscui_lw indscui_xw indscus_lw indscus_xw jbb
> gy jbsat jbsemp jbstat jsboss jspart jssize mastat_dv nchild_dv pidp pno psu rac
> el_dv sclfsato sex_dv strata tenure_dv ukborn urban_dv wkaut1 wkaut2 wkaut3 wkau
> t4 wkaut5"

.
.
.
. // These variables from the child files will be included. These include some key
> variables as determined by us PLUS any variables requested by you.
/ is not a valid command name
r(199);

.
. local chvars "age_dv chddvub_lw chddvub_xw chddvui_lw chddvui_xw country gor_dv
> hhsize hidp pidp pno psnen01_lw psnen91_lw psnenub_lw psnenub_xw psnenui_lw psne
> nui_xw psnenus_lw psnenus_xw psu sex_dv strata urban_dv"

.
.
.
. // These variables from the hhresp files will be included. These include some ke
> y variables as determined by us PLUS any variables requested by you.
/ is not a valid command name
r(199);

.
. local hhvars "country fihhmnnet1_dv gor_dv hhden01_xw hhden91_xw hhden99_xw hhde
> nub_xw hhdenui_xw hhdenus_xw hhsize hhtype_dv hidp ieqmoecd_dv nkids_dv psu stra
> ta tenure_dv urban_dv"

.
.
.
. // These variables from the youth files will be included. These include some key
> variables as determined by us PLUS any variables requested by you.
/ is not a valid command name
r(199);

.
. local youthvars "age_dv country ethn_dv gor_dv hidp pidp pno psu racel_dv sex_dv
> strata urban_dv ythscub_xw ythscui_xw ythscus_xw"

.
.
.
.
.
. ////////////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////////////////////////////////////
/ is not a valid command name
r(199);

.
. // Anything below this line should not be changed! Any changes to the selection
> of variables and waves, and location of folders, should be made above. //
/ is not a valid command name
r(199);

.
. ////////////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////////////////////////////////////
/ is not a valid command name
r(199);

.
.
.
. // this program returns all variable names with the wave prefix
/ is not a valid command name
r(199);

.
. program define getVars, rclass
1.
. version 14.0
2.
. if ("`1'" != "") {
3.
. local wavemyvars = " `1'"
4.
. local wavemyvars = subinstr("`wavemyvars'"," "," `2'_",.)
5.
. local wavemyvars = substr("`wavemyvars'",2,.)
6.
. }
7.
. else local wavemyvars = ""
8.
. return local fixedVars "`wavemyvars'"
9.
. end

.
.
.
. // this program to returns which variables exist in this wave
/ is not a valid command name
r(199);

.
. program define getExistingVars, rclass
1.
. version 14.0
2.
. local all = ""
3.
. foreach var in `1' {
4.
. capture confirm variable `var'
5.
. if !_rc {
6.
. local all = "`all' `var'"
7.
. }
8.
. }
9.
. return local existingVars "`all'"
10.
. end

.
.
.
. //loop through each wave
/ is not a valid command name
r(199);

.
. foreach wave in `allWaves' {
2.
. // find the wave number
3.
. local waveno=strpos("abcdefghijklmnopqrstuvwxyz","`wave'")
4.
.
.
. // find the wave household vars
5.
. getVars "`hhvars'" `wave'
6.
. local wavehhvars = "`r(fixedVars)'"
7.
.
.
. // find the wave individual vars
8.
. getVars "`indvars'" `wave'
9.
. local waveindvars = "`r(fixedVars)'"
10.
.
.
. // find the wave all individual vars
11.
. getVars "`indallvars'" `wave'
12.
. local waveindallvars = "`r(fixedVars)'"
13.
.
.
. // find the wave child vars
14.
. getVars "`chvars'" `wave'
15.
. local wavechvars = "`r(fixedVars)'"
16.
.
.
. // find the wave youth vars
17.
. getVars "`youthvars'" `wave'
18.
. local waveyouthvars = "`r(fixedVars)'"
19.
.
.
. // open the the household level file with the required variables
20.
. use "$ukhls/`wave'_hhresp", clear
21.
. getExistingVars "`wave'_hidp `wavehhvars'"
22.
. keep `r(existingVars)'
23.
.
.
. // if only household variables are required, skip this part and return all house
> holds
24.
. if ("`indvars'" != "" || "`chvars'" != "" || "`youthvars'" != "") {
25.
. // if any individual variable is required, first merge INDALL keeping the pipd
> (and possibly some default variables?), so that other files can merge on it.
26.
. merge 1:m `wave'_hidp using "$ukhls/`wave'_indall"
27.
. drop _merge
28.
. // drop loose households with no individuals
29.
. drop if (pidp == .)
30.
.
.
. // keep only variables that were requested and exist in this wave
31.
. getExistingVars "pidp `wave'_hidp `wavehhvars' `waveindallvars'"
32.
. keep `r(existingVars)'
33.
.
.
. // add any requested individual variables
34.
. if ("`indvars'" != "") {
35.
. merge 1:1 pidp using "$ukhls/`wave'_indresp"
36.
. drop _merge
37.
. // keep only variables that were requested and exist in this wave
38.
. getExistingVars "pidp `wave'_hidp `wavehhvars' `waveindvars' `waveyouthvars' `wa
> vechvars' `waveindallvars'"
39.
. keep `r(existingVars)'
40.
. }
41.
. // add any requested youth variables
42.
. if ("`waveyouthvars'" != "") {
43.
. merge 1:1 pidp using "$ukhls/`wave'_youth"
44.
. drop _merge
45.
. // keep only variables that were requested and exist in this wave
46.
. getExistingVars "pidp `wave'_hidp `wavehhvars' `waveindvars' `waveyouthvars' `wa
> vechvars' `waveindallvars'"
47.
. keep `r(existingVars)'
48.
. }
49.
. // add any requested child variables
50.
. if ("`wavechvars'" != "") {
51.
. merge 1:1 pidp using "$ukhls/`wave'_child"
52.
. drop _merge
53.
. // keep only variables that were requested and exist in this wave
54.
. getExistingVars "pidp `wave'_hidp `wavehhvars' `waveindvars' `waveyouthvars' `wa
> vechvars' `waveindallvars'"
55.
. keep `r(existingVars)'
56.
. }
57.
. }
58.
.
.
. // save the file that was created
59.
. save temp_`wave', replace
60.
. }
/ is not a valid command name
r(199);

.
.
.
. local firstWave = substr("`allWaves'", 1, 1)

.
.
.
. // open the individual level file for wave 1 containing the variables to use
/ is not a valid command name
r(199);

.
. local firstvar = subinstr("`joinvars'","#","`firstWave'",.)

.
. use pidp `firstvar' using "temp_`firstWave'", clear
file temp_h.dta not found
r(601);

.
.
.
. //sort by pidp and save
/ is not a valid command name
r(199);

.
. sort pidp
no variables defined
r(111);

.
. save "$outputpath/`outputfilename'", replace
no variables defined
r(111);

.
.
.
. // loop through the remaining waves
/ is not a valid command name
r(199);

.
. local remainingWaves = substr("`allWaves'", 1, .)

.
.
.
.
.
. foreach wave in `remainingWaves' {
2.
. // open the individual level file for that wave
3.
. use * using "temp_`wave'", clear
4.
.
.
. // sort by pidp
5.
. sort pidp
6.
.
.
. // merge with the file previously saved
7.
. merge 1:1 pidp using "$outputpath/`outputfilename'"
8.
. drop _merge
9.
.
.
. // sort by pidp
10.
. sort pidp
11.
.
.
. // save the file to be used in the next merge
12.
. order pidp, first
13.
. save "$outputpath/`outputfilename'", replace
14.
. }
/ is not a valid command name
r(199);

.
.
.
. // erase temporary files
/ is not a valid command name
r(199);

.
. foreach w in `allWaves' {
2.
. erase temp_`w'.dta
3.
. }
file temp_h.dta not found
r(601);

. log close
name: <unnamed>
log: D:\USF\issues\2066\2066 (option2).log
log type: text
closed on: 7 Mar 2024, 21:49:40
----------------------------------------------------------------------------------
(5-5/6)