Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: generate variable with the highest n-th non-missing value


From   "Grote, Veit Dr." <[email protected]>
To   <[email protected]>
Subject   st: generate variable with the highest n-th non-missing value
Date   Thu, 23 Jan 2003 13:16:50 +0100

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index