Hi, I have a variable which has been coded differently in two datasets. (old one for year 2000 and new one for year 2005 )
Old codes are { 2 4 5 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 3 28 29 31 6 32 17 33 30 }
New codes are { 28 18 10 24 6 2 1 29 32 23 27 14 17 13 21 3 8 11 33 16 9 19 35 12 4 26 7 30 31 15 34 25}
So, for example, the variable (lets call it state) was taking a value 2 earlier but in the new dataset that value corresponds to 28...... similarly 4 earlier and 18 now and so on
both the datasets have been appended with a variable called year taking value 2000 for old dataset and 2005 for new dataset.
How do I write a loop to convert the old codes for variable state to new one for the year 2000 so that the variable state can be made compatible across years ?
Related Posts with Loops to make variables compatible
stack data?Dear All, I have this data set. Code: clear input int A str12 B str9(C D) str18 E str9 F str15 G st…
creating a matrix in stata helpHello Stata Experts this forum has been helpful to me thank you so much i`m back with another issue …
How to fix error "outcome does not vary" for OR and logistic regressionDear all, I have been struggling to solve this. I imported data from excel file. And have a variabl…
estimates of variances in esttab for all the levelsI'm running a multilevel mixed model with: eststo: xtmixed y x1 x2 || country: || household:, reml e…
Problem with ado update: host not foundI just got the following Mata error message when running ado update: Code: . ado update note: ado u…
Subscribe to:
Post Comments (Atom)
0 Response to Loops to make variables compatible
Post a Comment