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

# Re: st: RE: Simultaneous occurance

 From Maarten buis To statalist@hsphsun2.harvard.edu Subject Re: st: RE: Simultaneous occurance Date Tue, 18 Mar 2008 17:19:25 +0000 (GMT)

```Here is an alternative:

gen byte indicator = mod(var1+var2,2)==0

The -mod- function is the modulus: the remainder after dividing the
first argument by the second argument. The two values have the same
value if the remainder of the sum divided by 2 is zero. This can be
generalized to three variables:

gen byte indicator = mod(var1+var2+var3,3)==0

etc.

Also notice that I use the trick explained in:
http://www.stata.com/support/faqs/data/trueorfalse.html

Hope this helps,
Maarten

--- Martin Weiss <martin.weiss@uni-tuebingen.de> wrote:

> Try this:
>
>
> ******
> clear*
> set obs 1000
> g byte var1=1 if uniform()<0.7
> replace var1=0 if var1==.
> g byte var2=1 if uniform()<0.5
> replace var2=0 if var2==.
>
> g byte indicator=var1==1 & var2==1 | var1==0 & var2==0
>
> ta var1 var2 if ind==0
> ta var1 var2 if ind==1
> ******
>
>
> Martin Weiss
> _________________________________________________________________
>
> Diplom-Kaufmann Martin Weiss
> Mohlstrasse 36
> Room 415
> 72074 Tuebingen
> Germany
>
> Fon: 0049-7071-2978184
>
> Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130
>
> Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131
>
> SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Olga
> Lyashevskaya
> Sent: Tuesday, March 18, 2008 4:56 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Simultaneous occurance
>
> Dear all,
>
> There are two binary variables in my sample, where 1
> is presence and 0 is absence of the particular
> characteristic. I want to identify those cases where I
> get either both 0's or both 1's
>
> Any suggestions?
>
> Thank you in advance,
> Olga
>
>
>
>
>
>
>
____________________________________________________________________________
> ________
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search.
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> *
> *   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/
>
> *
> *   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/
>

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

___________________________________________________________
Rise to the challenge for Sport Relief with Yahoo! For Good

http://uk.promotions.yahoo.com/forgood/
*
*   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/
```

 © Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index