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

Re: st: an egen command

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

Dear Jet

  I wonder if this example would help....

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...
Visit me on Facebook at...

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?

*   For searches and help try:
*   For searches and help try:

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