I have four variables (vacc~1 - vacc~4) giving the age of a vaccination. Three vaccinations are defined as "completed primary vaccination" (CPV). I like to find out the age of CPV.
vac~1 vac~2 vac~3 vac~4 Freq
2 49 . . 3
2 . . . 2
3 23 . 2 2
4 5 . 22 1
4 13 . . 1
4 5 . 25 1
With egen rfirst and rlast I can create a variable with the first and last non-missing value. In this case I like to create a variable with the 3rd non-missing value, like:
"egen cpv=rnth(vacc*1 vacc*2 vacc*3 vacc*4), n(3)"
Is there an easy solution like my egen vision?
Acctually it is more complicated as the logical age order within each person from vacc~1-vac~4 is not preserved. Thus, I need the third highest value in varlist vacc~1-vac~4.
Thanks for your help
Veit Grote
----------------------------------------
Dr. Veit Grote, MSc
Klinikum der Universit�t M�nchen
Dr. v. Haunersches Kinderspital
Lindwurmstr. 4
D-80337 M�nchen
Tel.: +49 (89) 5160-7798
Fax: +49 (89) 5160-2951
[email protected]
----------------------------------------
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/