Hello All,
I am using the updated STATA 17.
I downloaded a folder of files that are already in .dta format and ready to be run on STATA. My goal is to upload and loop each of them, but at one time. I know you cannot run a folder in STATA, but how do I run all the files in my folder? Pictures and my code below. I have checked and tried this many different ways and am at a loss. Thank you for your help in advance!
*Import and append all data from dta
*set the local space where you saved the dta file
global all_dta "/Users/emmaposey/Downloads/dta"
cd "$all_dta"
*import and append all data from dta
* Create a temp file to append all files to. This will become the main dataset.
tempfile data
save 'data', emptyok
*import all datasets and append:
local filenames : dir "${all_dta}" files "*.dta"
foreach f of local filenames {
use `"`f'"', clear // import file
gen source_dta = `"`f'"' // create variable with name file
}
Related Posts with Beginner User: Using all files within a folder
Problem with margins and vce(unconditional)Dear All, I am running a svy:probit and typing margins, vce(unconditional) later. However, I am ge…
Psmatch2 standard errorsI have conducted psm using kernel density matching. Since this produces multiple matches i need to a…
Possible bug in "label save" in Stata 16?Hi everyone, I wanted to bring this up in the forum in case I'm missing something obvious, and it's…
existing variable values as new variableshi my data goes like this: var1 var2 10000 a 10000 b 10000 c 10001 a 10001 b i want my data to loo…
Ipdmetan: how can I get p-values?Dear all, I am using IPDmetan after glm with different types of outcomes : count and continuous. Th…
Subscribe to:
Post Comments (Atom)
0 Response to Beginner User: Using all files within a folder
Post a Comment