Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   <benignor@javeriana.edu.co>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index