Statalist


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

st: AW: an egen command


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: an egen command
Date   Tue, 16 Feb 2010 11:47:59 +0100

<> 

You have already received valid answers. You may also like -irecode()- for
this purpose:


*************
sysuse auto, clear
su mpg, mean
gen byte var2=irecode(mpg,`r(mean)')

la def var2 0 "below mean" 1 "above mean"
la val var2 var2

table var2, contents(freq min mpg max mpg mean mpg ) row
*************

Note that -egen- is not part of the solutions here.


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jet
Gesendet: Dienstag, 16. Februar 2010 10:03
An: statalist@hsphsun2.harvard.edu
Betreff: st: an egen command

Hi, I am using egen to create new variables. Basically, I want to
recode a continuous variable into two groups, below or above the mean.
I tried this command: egen var2=cut(var), at (0, mean, maximum).
However, Stata turned out the maximum to be the mean. Any suggestion?
thanks.

Jet
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index