Statalist


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

Re: st: an egen command


From   Michael Norman Mitchell <[email protected]>
To   [email protected]
Subject   Re: st: an egen command
Date   Tue, 16 Feb 2010 01:13:52 -0800

Dear Jet

  I wonder if this example would help....

clear
sysuse auto

* say we want to split based on the mean of mpg
summarize mpg

* This will be spilt into a dummy variable, 0 is below mean mpg, 1 above
generate himpg = (mpg > r(mean)) if ! missing(mpg)

* show result
tab himpg

* compare result to original data
tabstat mpg, by(himpg) stat(min max)

I hope that is helpful to you.

Best regards,

Michael N. Mitchell
See the Stata tidbit of the week at...
http://www.MichaelNormanMitchell.com
Visit me on Facebook at...
http://www.facebook.com/MichaelNormanMitchell

On 2010-02-16 1.02 AM, Jet wrote:
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index