Statalist


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

RE: st: RE: Egen command


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Egen command
Date   Tue, 19 Aug 2008 19:09:58 +0100

Is this copied from a Stata dataset? Or from some spreadsheet or
similar? 

You have five variables here but in most cases only three values are
shown. 

What do the blanks mean? 

Eva's recent post may be what you want. I'm going off-line now. 

Nick 
[email protected] 

Ziad El-Khatib

Dear Nick,
Thank you.

Compliance= whether patients did take their drugs within a certain
range rate or not, defined as 95-110% of prescribed drugs on monthly
basis, in this cohort.

Kindly find below new example with pillcount variable.

studyid	visit	pillcount	pc2_24	pc36_104

1027	2	0		
1027	4	0		
1027	8	0		
1027	12	0		
1027	16	0		
1027	20	0		
1027	24	0	            0	
1027	36	0		
1027	52	0		
1027	78	0		                    0
1029	2	0		
1029	4	0		
1029	8	0		
1029	12	0		
1029	16	0		
1029	20	0		
1029	24	0	            0	
1029	36	0		
1029	52	0		
1029	78	1		
1029	104	0			            1


ID 1027 did drop out before week 104 on treatment but still counted her.
ID 1029 has example of patient coming to all visits.



Hope this helps?
Thank you again and best regards
ziad





On Tue, Aug 19, 2008 at 10:33 AM, Nick Cox <[email protected]> wrote:
> You should keep away from -egen, count()-.
>
> What does the help say?
>
> count(exp) (allows by varlist:) creates a constant (within varlist)
> containing the number of nonmissing observations of exp.
>
> Your exp (i.e. expression) is -pillcount-. So you are counting whether
> -pillcount- is non-missing. 1 is non-missing. 0 is non-missing. Any
> other non-missing value is non-missing. All observations with any of
> these non-missing values will be counted.
>
> That is, I gather, not at all what you want.
>
> I am less able to work out precisely what you do want. I could make
some
> guesses but I think it is better if you explain. Do remember that many
> of us are not biostatisticians or medics and so, like me, may be fuzzy
> on what on earth compliance is.
>
> Your examples do not include any with data for the key variable
> -pillcount-.
>
> Nick
> [email protected]
>
> Ziad El-Khatib
>
> 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

*
*   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