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
Simulating the Dickey Fuller distribution in StataDear all, Hope you are all well. Can I ask if there is a way of simulating the Dickey Fuller distr…
interaction effect in instrument variable probit modelDear All, my query is related to the interaction effect in the instrument variable probit model. Whe…
datetime of march 31, 2012Dear All, I have this data set Code: * Example generated by -dataex-. To install: ssc install datae…
Modifying dataset for relative time modelArray Array Array Array P.S. To express notation correctly, I uploaded the screenshot of my post. …
How to group connected dates?I have a panel containing daily data which are not all continuous. Within an ID, if those dates are …
Subscribe to:
Post Comments (Atom)
0 Response to Append and recode multiple datasets at once
Post a Comment