Hello everyone,
I know that this has been addressed and answered multiple times, however I am very new to Stata and I can't seem to understand how this works.
I have a folder with data from the UKHLS (UK Household Longitudinal Survey). The folder is named w_indresp and contains 9 items; a_indresp, b_indresp up to i_indresp.
I want to append e_indresp, f_indresp, g_indresp h_indresp and i_indresp to create a new file, say; appended_indresp.dta . I am using the following code, directly from the UKHLS website, however it doesn't seem to work and i am guessing that the problem seems to be coming from the way I have saved my files, or I am missing some initial steps/procedures regarding directories(?).
foreach w in a b c d e f g h i {
local local waveNr = index("abcdefghi", "`w'")
use 'w'_variable1 pidp `w'_variable2_dv `w'_variable3 `w'_variable_dv
using "C:...\\My Documents\Project\Data\w_indresp/'w'_indresp"
rename 'w'_* *
generate wave = 'waveNr'
if indexnot("a", "'w'")
append using "C:...\\My Documents\Project\Data\w_indresp/'w'_indresp"
save "", replace
}
Whenever I use this code, i am getting the following error message: file w_indresp not found
Could someone explain if and what I am doing wrong? Again, i think the problem is in the folders with the .dta files.
Also, apologies for adressing this issue again, but ive only used Stata twice.
Many thanks for the time and help!!
Konstantinos
Related Posts with Loop Append Multiple Waves of dta
Replacing values with exisiting onesDear All, I have three variables in my dataset, ID, year, and object. The "object" is a categorical…
The Null hypothesis of t-test in non-linear least-squares ?I'm reading a paper named "Flows of knowledge from universities and federal laboratories:Modeling th…
Create variable - mean per ageHello, I would like to create a variable that says the mean value of income (prfitba_w3) by age (dv…
Changing axes font in graphHi. I'm struggling to change the font of the x and y axes of a line graph. The following code change…
The Null hypothesis of t-test in non-linear least-squares ?I'm reading a paper named "Flows of knowledge from universities and federal laboratories:Modeling th…
Subscribe to:
Post Comments (Atom)
0 Response to Loop Append Multiple Waves of dta
Post a Comment