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: identifying observations where multiple conditions are met
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: identifying observations where multiple conditions are met
Date
Wed, 13 Nov 2013 16:38:47 -0500
On Wed, Nov 13, 2013 at 4:08 PM, Michael McCulloch
<[email protected]> wrote:
> Thanks Sergiy for the simulation & code.
>
> I note that the command
> . tabulate id if flag
> will identify both the problem observations I want to drop (where for the same -id-, that -type- is not unique, there are observations of both kinds, type==0 and type==1), but also also ones in which for -id-, that -type- is in fact unique, but there is only ONE observation.
If singleton observations are acceptable for your algorithm, then
modification can be:
replace flag=1 if flag!=0 & !missing(flag)
tab id if flag==1
Best, Sergiy
>
>
> Best wishes,
> Michael McCulloch
>
> --
> Pine Street Foundation, since 1989
> 124 Pine Street | San Anselmo | California | 94960-2674
> P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org
>
> On Nov 13, 2013, at 12:38 PM, Sergiy Radyakin wrote:
>
>> //------------------------------------------
>> clear
>> set obs 100
>> gen id=floor(_n/2)
>> gen type=floor(uniform()*2)
>> //------------------------------------------
>> sort id
>> by id: egen flag=sd(type)
>> replace flag=1 if flag!=0
>>
>> Best, Sergiy Radyakin
>>
>>
>> On Wed, Nov 13, 2013 at 3:24 PM, Allred, Elizabeth
>> <[email protected]> wrote:
>>> Have you tried:
>>>
>>> tab id if type==0 | type==1
>>>
>>> -----Original Message-----
>>> From: [email protected] [mailto:[email protected]] On Behalf Of Michael McCulloch
>>> Sent: Wednesday, November 13, 2013 3:14 PM
>>> To: [email protected]
>>> Subject: st: identifying observations where multiple conditions are met
>>>
>>> Hello,
>>> I have data of the structure:
>>> id (range 1 to 300)
>>> type (for each -id-, should equal only one of two values: 0 or 1).
>>>
>>> In manual inspection of the data, I see instances exist where, for the same -id-,
>>> some records have type==0, and
>>> other records have type==1.
>>>
>>> If I enter
>>> . tab id if type==0 & type==1
>>> obviously "no observations" is returned.
>>>
>>> How would I write a command in which I can tabulate all -id- for which some observations exist where type==0, and others where type==1? (At data entry, -type- should have unique for each -id-.)
>>>
>>>
>>> Best wishes,
>>> Michael McCulloch
>>>
>>> --
>>> Pine Street Foundation, since 1989
>>> 124 Pine Street | San Anselmo | California | 94960-2674
>>> P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org
>>>
>>>
>>> *
>>> * For searches and help try:
>>> * http://www.stata.com/help.cgi?search
>>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>>> * http://www.ats.ucla.edu/stat/stata/
>>>
>>> *
>>> * For searches and help try:
>>> * http://www.stata.com/help.cgi?search
>>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>>> * http://www.ats.ucla.edu/stat/stata/
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>> * http://www.ats.ucla.edu/stat/stata/
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/