Hello,
I have a large number of datasets that have very long filenames but each have a unique string within the filename (in this instance "country"). The files are not mine so I cannot change the names of the files, but would like to read in all the files into Stata based on a part of the filename, for example a file name could be:
"file 1 project 102 temporary data sweden individualpatientdata.dta"
or
"file 8 project 103 temporary data norway individualpatientdata.dta"
Now, could I use the string part that is based on country to read in the dataset? Obviously, the following wouldn't work:
.use "$data/*sweden*.dta , clear
.use "$data/*norway*.dta , clear
but that is essentially what I would like to do. All the files sit on separate drive (F) so I could store the file names in a local like this,
.local myfiles: dir "F:/" files "*.dta"
but then I do not know how to continue.
Any help would be much appreciated!
Thanks,
Raoul
Related Posts with Read Stata file using part of file name only
Deleting some observations within a variable when conditions are metHi everyone, I have a datasets which looks like this: Code: * Example generated by -dataex-. For …
Merge 2 datasets: individual and county level datasetsI need to merge two datasets. One has individual-level data and the other has county-level data. I…
Help with multilevel survival analysisI am currently conducting a study that follows patients over 30 days to see if they have an event. P…
Marginal effect after system GMM continuous variables penal dataHi experts and researchers, I am using interactive terms in my research and I need to understand ho…
Error when use xtcsd (_variable merge already defined)Hi, I have a problem when I use xtcsd. After I run using xtreg depvar indepvar, fe , and then use "x…
Subscribe to:
Post Comments (Atom)
0 Response to Read Stata file using part of file name only
Post a Comment