Hi
I was hoping to import efficiently some data with a little local programming but I am employing more time in devising a way to do so than I would have used copying and pasting, so I presume to ask for help.
Suppose I have a file with viral load for each of a number of individuals, named after the individual, with suffix _VL.tab (exported from a database by hand). The ID for such individuals are in another file, "missing longitudinal.csv". The data collected are already in the file "VL.dta", which contains the variables ID VL date. Everything is in the current directory.
The loop runs but does not produce anything. Nor does it even return an error. The correct values are shown upon creation of the local but display does not show its content.
What am I doing wrong? Thanks much,
NL
insheet using "missing longitudinal.csv", clear names
drop if ID==""
levelsof ID, local(individuals)
foreach ID of local individuals{
insheet using `ID'_VL.tab, names clear
keep v2 v3
rename v2 date
rename v3 VL
gen ID=ID
append using VL
save VL, replace
}
I was hoping to import efficiently some data with a little local programming but I am employing more time in devising a way to do so than I would have used copying and pasting, so I presume to ask for help.
Suppose I have a file with viral load for each of a number of individuals, named after the individual, with suffix _VL.tab (exported from a database by hand). The ID for such individuals are in another file, "missing longitudinal.csv". The data collected are already in the file "VL.dta", which contains the variables ID VL date. Everything is in the current directory.
The loop runs but does not produce anything. Nor does it even return an error. The correct values are shown upon creation of the local but display does not show its content.
What am I doing wrong? Thanks much,
NL
insheet using "missing longitudinal.csv", clear names
drop if ID==""
levelsof ID, local(individuals)
foreach ID of local individuals{
insheet using `ID'_VL.tab, names clear
keep v2 v3
rename v2 date
rename v3 VL
gen ID=ID
append using VL
save VL, replace
}
Comment