[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: Create categorical variable based on 'z-score' |

Date |
Wed, 26 Nov 2008 20:58:49 -0000 |

You want to round up when positive, down when negative. egen z = std(foo) replace z = cond(z == 0, 0, cond(z > 0, ceil(z), floor(z))) Nick n.j.cox@durham.ac.uk George Hoffman Thanks, nick. Egen std works. Can I nest floor(ceil(x)) to get the desired ...? Nick Cox <n.j.cox@durham.ac.uk> > Despite various answers, no one mention -egen, std()- followed by > -floor()- and -ceil(). All existing official Stata. George Hoffman > Generic problem: I'd like to create categorical variables for a list of > continuous variables. The categorical variables would be based upon the > z-score of each variable, such as: > Z-score of X catX > <-2 -3 > -2 ..-1 -2 > -1 .. 0 -1 > 0 0 > 0.. +1 +1 > 1 ..2 +2 >> +2 +3 > > If there were a way to z-transform variables, I could do an easy > recode(catX) * * 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/

**Follow-Ups**:**RE: st: RE: Create categorical variable based on 'z-score'***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: Create categorical variable based on 'z-score'***From:*George Hoffman <ghoffman@mcw.edu>

**References**:**st: RE: Create categorical variable based on 'z-score'***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: Create categorical variable based on 'z-score'***From:*George Hoffman <ghoffman@mcw.edu>

- Prev by Date:
**re: st: Question about options in "xtreg, re"** - Next by Date:
**st: RE: RE: Re: Poststratification weights** - Previous by thread:
**Re: st: RE: Create categorical variable based on 'z-score'** - Next by thread:
**Re: st: RE: Create categorical variable based on 'z-score'** - Index(es):

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