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