The code you have shown us defines a variable with values 0 or 1.
That doesn't tally with the problem you report here, of giving a
cumulative number. I guess that refers to some code you don't show us.
However, on the final question, assume variables
id
pillcount
week
egen everLT95 = max(pillcount < 95 & week >= 2 & week <= 24), by(id)
egen tag = tag(id)
count if everLT95 & tag
See also the manual entry for -egen- and the FAQ
http://www.stata.com/support/faqs/data/anyall.html
and my articles
2007. Speaking Stata: Making it count.
Stata Journal 7(1): 117-130
2007. Speaking Stata: Counting groups, especially panels.
Stata Journal 7(4): 571-581.
Nick
[email protected]
Ziad El-Khatib
it is giving me the accumulative number of patients over period of
time weeks 2-24.
How I can count patients in individual way, i.e. just to know how many
patients did ever report pill count<95 during weeks 2-24?
Ziad El-Khatib
>> My dataset has different time points, weeks 2,4,8,12,16,20,24,36 and
>> 52 weeks on treatment.
>> I want to look at the adherence level during the weeks 2-24, I tried
>> this code, but it didn't give me what I wanted:
>>
>> gen adherence =0
>> replace adherence =1 if pillcount <95 & (week>=2|week<=24)
*
* 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/