Hi,
I am fairly new to stata and am trying to figure out a way where I can recode variables across multiple datasets and have the new recoded variables be saved into 1 aggregate data file. For context, I have 14 files all named: file_1.dta , file_2.dta, .... file_14.dta
For this example, I have a variable MCREV06 where the 06 is the given year
Code:
cd "/Users/octavio/Desktop/MEPS"
clear
foreach i in file_1.dta file_2.dta file_3.dta file_4.dta file_5.dta file_7.dta file_8.dta file_9.dta file_10.dta file_11.dta file_12.dta file_13.dta file_14.dta {
use file_`i'.dta
keep MCREV`num'
gen EVERMEDICARE=0
replace EVERMEDICARE=1 if MCREV`num'==1
append using file_`i'
save aggregatedatafile
}
Related Posts with Append and recode multiple datasets at once
tab2xl command only saving zeroesHi. I was looking to export some cross-tabulations to excel and I came across -tab2xl-. The command …
Calculating number needed to treat after competing risk regressionsHi Statalist, I am interested how to use Stata to calculate a number needed to treat statistic foll…
Bivariate scatter plot with observations colored according to the clustersI performed K-Means clustering and am trying to graph two of my variables on a scatter plot, but nee…
NYLS 1979 Panel Data set - nonlinear regressionHello All, I am using the NYLS 1979 data set and I have 12,686 individuals over 26 years. I am look…
After an estimation with fixed effects, my e(b) matrix dmension change from a computer to anotherHi, After an estimation with fixed effect (with OLS or PPML) such as "ppml v dist contig tariff FE_…
Subscribe to:
Post Comments (Atom)
0 Response to Append and recode multiple datasets at once
Post a Comment