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
Dropping Observations and Creating Fertility VariableQuestion 1: I am using two fertlity variables- age at first intercourse (var name: age1stsex) and a…
Deleting files from folder based on sting conditionHello! I am seeking your help with the following task. Say, I have a folder called Files that conta…
Calculating the mean of categories of a variable created using -egen, cut()-Can someone kindly explain how I can calculate the mean of each wealth category by race or other cha…
Two questions on fixed effects in stataHello, Can someone please help me understand two issues I have? I am doing a gravity model with pa…
How do I reference an estimate after lincom?Hi Everyone: I know there must be a simple solution to this but I haven't found it. I thought that u…
Subscribe to:
Post Comments (Atom)
0 Response to Creating filename as columns in multiple files dta files before appending
Post a Comment