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
bubble chart for groupsHi, I am quite new to stata and want to create a bubble chart for visualizing frequencies within a …
Merge 7 datasetsHello. I have seven different datasets (one per year from 2007 to 2013) with all the variable being…
Store r-class values and tabulate laterHello all, I am new to stata and my work is about medical data. My data are about diagnostic perfor…
Expand rolling sequencies of observation within ID ifHi, I am using a panel dataset with different countries (example below). For each date there are tw…
Creating a panel dataset using STATAHello colleagues I am analysing the impact of COVID 19 on firms. I want to use two waves of the Wor…
Subscribe to:
Post Comments (Atom)
0 Response to Syntax for using and merging multiple tempfiles
Post a Comment