Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Calculating a maximum out of a subset in a sequence


From   <[email protected]>
To   [email protected]
Subject   st: Calculating a maximum out of a subset in a sequence
Date   Mon, 3 Oct 2011 18:16:09 -0400

Dear list:

I have a panel dataset with a subject identifier (patid), a time
identifier (week1), and two variables of interest (C4NAIVC and
CD4MEMC), some of which contain missing observations for some
subjects at some time points. I am interested in obtaining, for each
subject, the latest timepoint when either C4NAIVC and CD4MEMC or both
were available.

I tried:

. bysort patid: egen LatestNaive = max(WEEK1) if (C4NAIVC ~=.|CD4MEMC ~=.)
(252 missing values generated)

But this simply produced a missing value in the record that contained
a missing C4NAIVC or CD4MEMC. It still took all week1 values into
account to calculate the maximum. So, if somebody had a missing value
at week 96 but not at week 196, LatestNaive was still 196.

Any suggestions?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index