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
Frequency bar graph for multiple binary variablesI have a string variable (Reasons_Inadmissible) with multiple values that are comma separated. It li…
Is it possible to destring a variable which starts with a letter?Hello, I am using Parliamentary Constituency codes (variable name _pcon) in my dataset which begin w…
Bug fix for estimates table and estout/esttab in Feb 20 update of Stata 15In the latest update of Stata 15 (from Feb 20, 2019), models with ancillary parameters can cause pro…
generate variable time to event. Several measures in time.Please, I need to create a variable event and time to event. But I have different measures. The vari…
displaying the contents of a macroHi all: I am using "macro list" to display the contents of all the macros I have created (locals and…
Subscribe to:
Post Comments (Atom)
0 Response to Syntax for using and merging multiple tempfiles
Post a Comment