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
Parallel trends assumption test for a two way fixed effect model (omitted treatment variable)Hi everyone, I want to test for the parallel trend assumption in the difference in differences. My …
Help for replacing parts of a string variableDear community, I want to clean a string variable that contains the name of a bank. Sometimes, it a…
Set base group for 2 variables when including interaction terms in a regressionDear all, I am currently running a regression in Stata that involves an interaction term between ye…
Results of the Hsiao procedure for the homogeneity test on panel dataHi Statalists, I work on a panel of 5 individuals and 38 years. I performed the Hsiao test to test …
Gologit 2 interpretationHi everyone, I have read Williams' article about Gologit2 model. I have some concerns about the inte…
Subscribe to:
Post Comments (Atom)
0 Response to Append and recode multiple datasets at once
Post a Comment