I used Stata tempfile code from one of the earlier
posts to append multiple years of NHIS mortality data. The code worked perfectly. However, I had to manually generate interview year variable in each data set before appending them. I'm hoping anyone can show me how to generate a new variable - year - as it will help me generate other variables. Here is a code I used
Code:
clear
set more off
local flist: dir "." files "*.dta"
use NHIS_1986_MORT_2011_PUBLIC //is there a way to run the code without specifying the using dataset?
local mort = 0
foreach fname of local flist {
local ++mort
tempfile temp`mort'
save "`temp`mort''"
}
forval i = 1/`mort' {
append using "`temp`i''"
}
0 Response to Generate with tempfiles
Post a Comment