Bookmark and Share

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: creating group property in a panel data


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: RE: creating group property in a panel data
Date   Thu, 26 Apr 2012 15:18:06 +0100

Strictly, the names are not all quite right. Say alcohol is indicated by 1 and non-alcohol is 0. Then 

max over values that might be 0 or 1 will be 1 if any value is 1. 

and 

min over values that might be 0 or 1 will be 0 if any value is 0. 

So the name -ever_nonalcohol- is not right. -ever_nonalcohol- will be 0 if any value is 0 and 1 otherwise, so it is an _inverted_ indicator variable. 

See also 

FAQ     . . Creating variables recording whether any or all possess some char.
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        2/03    How do I create a variable recording whether any
                members of a group (or all members of a group)
                possess some characteristic?
                http://www.stata.com/support/faqs/data/anyall.html

Nick 
[email protected] 


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Caliph Omar Moumin
Sent: 26 April 2012 14:52
To: [email protected]
Subject: Re: st: RE: creating group property in a panel data

Thx Nick. That was helpful


Kind Regards,
Moumin

Email:  [email protected] 



----- Original Message -----
From: Nick Cox <[email protected]>
To: [email protected]
Cc: 
Sent: Thursday, April 26, 2012 3:00 AM
Subject: Re: st: RE: creating group property in a panel data

My typo. I mixed names. You want

. gen both = ever_alcohol!=ever_nonalcohol

On Wed, Apr 25, 2012 at 9:39 PM, Caliph Omar Moumin
<[email protected]> wrote:
> Thx Nick for ur quick reply.
>
> Yes it seems exactly like you indicated below.
>
>
> Nr  groupdiag
>
> 123  0
> 123  0
> 123  1
>
> 234  0
> 234  0
> 234  0
>
> 345  1
> 345  1
>
>
>  When i tried to apply your instruction,
>
>  the last command which is
>
> gen both = is_alc != is_nonalc
>
>  does not execute. I do not know if this solves my problem or not
>
> in my dataset it looks like this
>
> egen ever_alcohol = max(groupdaig), by(Nr)
>
> . egen ever_nonalcohol = min(groupdaig), by(Nr)
>
> . gen both = is_alcohol!=is_nonalcohol
>
> stata error
> is_alcohol not found
> r(111);
>
> I would appreciate if you could help?
>
>
>
>
> Kind Regards,
> Moumin
>
> Email:  [email protected]
>
>
>
> ----- Original Message -----
> From: Nick Cox <[email protected]>
> To: "'[email protected]'" <[email protected]>
> Cc:
> Sent: Wednesday, April 25, 2012 7:28 PM
> Subject: st: RE: creating group property in a panel data
>
> It seems that you have something like this:
>
> id   diagnosis
>
> 123   0
> 123   0
> 123   1
>
> 234   0
> 234   0
> 234   0
>
> 345   1
> 345   1
>
> And you are interested in classifying patients.
>
> If you go
>
> egen ever_alc = max(diagnosis) , by(id)
> egen ever_nonalc = min(diagnosis) , by(id)
> gen both = is_alc != is_nonalc
>
> you may get something relevant. Otherwise I think we need to see a clear example, as your word description is a bit fuzzy.
>
> Nick
> [email protected]
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Caliph Omar Moumin
> Sent: 25 April 2012 18:16
> To: [email protected]
> Subject: st: creating group property in a panel data
>
> dear statlist
>
> My panel data is patient registry of one year which includes variable ID,  and variable daignosis. I group classified daignosis into two groups
> those related to alcohol and those not related to alcohol.
>
> so a varaible name called groupdaig is created with 0 for non-related to alcohol and 1 = for related to alcohol. That was so far good.
>
> since my data is a panel data same observation in the ID variable is included in both non-alcohol related daignosis and the alcohol related diagnosis.
>
> How can i make unique property, or code to this group? the observatios (patients) which are treated both alcohol and non-alcohol related daignosis?
>
> I tried to apply this
> http://www.stata.com/support/faqs/data/members.html
>
> but i didn't fit to my data structure.
>
>
> Kind Regards,
> Moumin
>
> Email:  [email protected]
>
>
> *
> *   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/
>
> *
> *   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/
>
>
> *
> *   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/

*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/


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

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index