Hi,
I am trying to include the name of the file as a variable before appending. Please see code below, which works well.
ideally the variable should be created after importing the delimited file, but before saving as a dta file for all files to be appended
Thanks
clear
cd "C:\Users\aaaa"
local files: dir "C:\Users\aaaa" files "*.txt"
foreach file in `files' {
clear
import delimited `file'
save `file'.dta, replace
}
local files: dir "C:\Users\aaaa " files "*.dta"
foreach file in `files' {
append using `file'
}
Related Posts with Creating filename as columns in multiple files dta files before appending
Global macro: How to remove a variable?I created a macro of available variable names in my dataset ($vitamins): Code: global vitamins vit…
problem with multiple if conditionsI am having issues with using multiple if conditions with replace function. I have two variables i.e…
SimulationHello guys, I'm trying to run a bootstrapping simulation just like here: https://www.statalist.org/…
Any literature on Correlated Random Effects (CRE) with selection correction?Hello all, I am looking for the papers I can refer to regarding the selection correction in the cor…
Differences-in-Differences with ModeratorsHello all, I could use some input as to how to go about a research design that I am look at doing.…
Subscribe to:
Post Comments (Atom)
0 Response to Creating filename as columns in multiple files dta files before appending
Post a Comment