Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Egen command


From   "Ziad El-Khatib" <[email protected]>
To   [email protected]
Subject   st: Egen command
Date   Tue, 19 Aug 2008 10:17:00 -0700

Hi!
I have cohort dataset monitoring patients' compliance to drugs over 11
time points (weeks 2, 4, 8, 12, 16, 20, 24, 36, 52, 78 and 104 after
starting on drugs).
I want to look at the persistence of their compliance over weeks 2-24
versus 36-104, i.e. OR of not missing any pill at all over all this
visits between weeks 2-24 versus 36-104.

At every visit I coded pillcount as 0/1: 1 if patient was not
compliant versus 0: if patient was compliant.

Now trying to create pc2_24 for weeks 2 to 24, and pc36_104 for week
36 to 104 to code them as 0/1 (compliant/not compliant).

I tried
egen pc2_24=count(pillcount),by(studyid), if visit>0&visit<25

So got

studyid	visit	pc2_24
1003	2	1
1003	4	1
1003	8	1
1003	12	1
1003	16	1
1003	20	1
1003	24	1
1005	2	1
1005	4	1
1005	8	1


But I want the result to look like:
studyid	visit	pc2_24
1003	2	
1003	4	
1003	8	
1003	12	
1003	16	
1003	20	
1003	24	1
1005	2	
1005	4	
1005	8	
1005	12	
1005	16	
1005	20	
1005	24	1


so only to show number 0 or 1 at the last visit, whether visit number
24, 20 , or else that is <24


Any tips?


Thank you and best regards
ziad
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index