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
3SLS fixed effects with panel dataI am trying to perform 3SLS with fixed effects in stata 16 and the command I put in is accepted and …
Any stata code for calculating adjusted number needed to be exposed (NNE)?Hello, I was wondering is there any Stata code available for calculating adjusted number needed to …
help with rowlast or rowfirstHello In my data, I have a number of columns beginning with gp_code_* ( aroound 100, but only a few…
selection Problem out of huge amount of occupationsDear Stata Community, Iam almost new to stata and Iam kind of stuck with a problem. May someone can…
heatplot assistanceHello dear statalist members, I'm working with the heatplot command and I have an issue with the lo…
Subscribe to:
Post Comments (Atom)
0 Response to Beginner User: Using all files within a folder
Post a Comment