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]
Re: st: RE: Tabulating data with multiple visits--repost
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: RE: Tabulating data with multiple visits--repost
Date
Sat, 5 Mar 2011 11:19:34 +0000
Perhaps you should also look at -collapse- to get a reduced dataset based on
people, not visits.
On Fri, Mar 4, 2011 at 8:47 PM, Nick Cox <[email protected]> wrote:
> bysort id (clear) : gen isclear = clear[_N]
> by id : gen nvisits = _N
> by id : gen tag = _n == _N
>
> l id nvisits isclear if tag
>
> See also -groups- from SSC.
> On Fri, Mar 4, 2011 at 8:19 PM, Tasha Amin <[email protected]> wrote:
>> Yeah, the formatting got messed up in the email. Apologies. Let me try writing the dataset thus to represent individuals with multiple visits and binary variable "clear":
>>
>>
>> ID: 1,2,3,4,5 corresponding to 5 individuals
>>
>> visits: ID 1 had visits (1,2,3,4,5), 2 had visits (1,3,4), 3 had visits (1,2), 4 had visits (1,2,3), 5 had visits (1,2,3)
>>
>> clear: ID 1 cleared on visit 4 so had clear (0,0,0,1,1), 2 clear (0,0,1),3 clear (0,0),4 clear (0,1,1),5 clear (0,0,0)
>>
>>
>> I want to know how many people had "clear=1" by counting the IDs once, not the visits. Correct output for frequency of "clear" would be 3 (for IDs 1, 2, and 4), NOT 5 from the visits. Does that make sense?
>>
>> ----------------------------------------
>>> From: [email protected]
>>> To: [email protected]
>>> Date: Fri, 4 Mar 2011 19:51:57 +0000
>>> Subject: st: RE: Tabulating data with multiple visits--simple question
>>>
>>> This doesn't look simple at all to me in so far as your data example is unclear to me in my mailer, at the StataCorp version of the archives, and at the HSPH version too.
>>>
>>> Perhaps someone else can figure it out. If not, please post again with clear structure to data example.
>>>
>>> Nick
>>> [email protected]
>>>
>>> Tasha Amin
>>>
>>> Sorry for how simple this is. Having too many problems with it so far.
>>> I have data with multiple visits by the same person and would like to summarize results by counting their id's only once. How do I tabulate it? Data looks like
>>> ID visits clear1 1 01 2 0 1 3 11 4 11 5 12 1 02 2 13 1 0 4 1 04 2 1
>>> When tabulating, I would like the frequency of "clear" to be 3 (corresponding to ID's 1,2, and 4) NOT 5, based on visits. Please help. Thanks!
>
*
* 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/