Hi all
I have hospital admissions data, organised so each observation is an admission. There is a variable for ethnicity, but for some patients this is different between admissions. (Likely because the way people identify changes over time, and because we can record multiple ethnicities in our admissions data, and what is recorded may differ). I want to create a variable for prioritised ethnicity, using the priority allocation system used in my country.
The data looks like
id ethnicity other variables ...
1 3
1 3
2 10
3 11
3 15
3 11
I have generated a new prioritised ethnicity variable using the current ethnicity variable. I then want to replace prioritised ethnicity values with whichever value ranks higher in our allocation system.
I have tried:
generate ethnic2 = ethnic
label variable ethnic2 "Prioritised ethnic group - unified across admissions"
quietly by id: replace ethnic2 = 21 if ethnic2 == 21 // Maori is priority 1
quietly by id: replace ethnic2 = 35 if ethnic2 == 35 // Tokelauan is priority 2
quietly by id: replace ethnic2 = 36 if ethnic2 == 36 // Fijian is priority 3
....
I didn't think this was quite right and it wasn't - when I count before and after the commands the number of admissions with each ethnicity recorded doesn't change.
Any ideas how to do this?
Many thanks
Kate
Related Posts with Creating a prioritised ethnicity group variable
delete observations conditionallyDear All, I find this question here (https://bbs.pinggu.org/forum.php?mod...=1#pid57289524). The dat…
ItsaDear I am new using time series analises in stata, so need some help. I am try to use the ITSA comma…
Offset() option in Poisson/negative binomial regressionHello everyone, I am working on count data and have the follow-up time in days. Do I need to log-tr…
Merge (m:1) and data orderingHi all, please consider the following data example: Code: /*clear . input str6 id byte str4 loc …
How to write a heckman selection model whose second stage is a finite mixture modelDear statalist: I want to do a heckman seclection model whose second stage is a fmm by joint maximu…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a prioritised ethnicity group variable
Post a Comment