I have been given a dataset (it is a translation table) to use that is set up in a fairly disorganized fashion. It has multiple variables that contain the same type of IDs (although the values in each vary slightly). I need to merge all of these together into one variable, while keeping the other variables. When I try to use the tempfiles I have saved I receive an invalid file specification error, I'm guessing this is just a syntax error on my part, but I have been unable to find a fix through googling so far. My code:
tempfile baseDict
save "`baseDict'"
keep Main_ID
tempfile MainID
save "`MainID'"
foreach year in 2012/2016 {
use `baseDict'
keep *_`year'
rename ID_`year' Main_ID
tempfile yearIDs
save "`yearIDs'"
use `MainID'
merge 1:1 Main_ID using "`yearIDs'"
save "`MainID'"
}
Set trace seems to show the error ocurring right as the first use `baseDict' runs in the for loop. Any help is quite appreciated, thank you!
Related Posts with Syntax for using and merging multiple tempfiles
How STATA Works With Missing Data in Panel Data RegressionI will be grateful if anyone here could help me with panel data regression using STATA. I am current…
keep the variable if it's value(name) exist in another fileHello! I have two databases, one is in CSV and the other is on XLSX. Both files contain a variable …
Question about Stata close button on MacBook?Dear all, My Stata version is Stata 17 (MP 4) and on MacBook Air.I find that the close button's colo…
How to retrieve all the coefficient of independent variables of did_imputation package?Hi all, Normally, in a research paper, we need to present a table of coefficients of all independen…
How to calculate a value from a stringColleagues, I have a dataset with a land-use description codified with a alphanumeric string. Some …
Subscribe to:
Post Comments (Atom)
0 Response to Syntax for using and merging multiple tempfiles
Post a Comment