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
Import excel date format instead of general numberHi, I'm importing an excel spreadsheet (downloaded/refreshed from Datastream, the data provider) bu…
report var(residual) / melogit vs. xtmixed ?l am working about cross-classified multilevel model dependent variable : immigration y/n (binary, …
How to count the number of missing values?How to count the number of missing values? I have a simple question I would like to know asap. How …
Lagged variable and panel structureDear Statalists At the moment I am dealing with a apparently simple problem. The following data ser…
rename all variablesHello everyone, I am trying to rename ALL variables in my dataset. The end results are supposed to …
Subscribe to:
Post Comments (Atom)
0 Response to Loop Append Multiple Waves of dta
Post a Comment