# st: RE: RE: identifying even & odd numbers

 From "Nick Cox" To Subject st: RE: RE: identifying even & odd numbers Date Tue, 30 Mar 2004 19:25:31 +0100

```As a proof this would be fallacious. I'm guessing
from context that -oldvar- consists of integers only.

Nick
n.j.cox@durham.ac.uk

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
> Sent: 30 March 2004 19:17
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: identifying even & odd numbers
>
>
> gen odd = mod(oldvar,2)
>
> Rationale: if the remainder on dividing -oldvar- by
> 2 is 1, then -oldvar- is odd; otherwise it is even.
>
> Nick
> n.j.cox@durham.ac.uk
>
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu
> > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of
> Danielle H.
> > Ferry
> > Sent: 30 March 2004 19:10
> > To: statalist@hsphsun2.harvard.edu
> > Subject: st: identifying even & odd numbers
> >
> >
> > Hi,
> > I apologize if this has been addressed previously. I haven't found
> > anything in the archives, though I feel as though it surely must be
> > there somewhere. I am wondering if there is a way to create a new
> > variable that takes on a value if another variable is an even
> > or an odd
> > number. For example, can you do something like this:
> > ge newvar = 1 if oldvar is even
> > If this has made its way thru the list before, perhaps someone can
> > suggest better search keywords for the archives? Thanks.
> > Danielle Ferry
> > *
> > *   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/
>

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