Dear Stata users,

In the funtion -egen-, we can invoke -egen newvar=cut(var), group(#)- to generate a new categorical variable. And the option group(#) specifies the number of equal frequency grouping intervals to be used in the absence of breaks. But actually this sentence cannot always give us equal frequency groups. And I also want to know the difference between -egen, cut()- and -xitle-. Thank you very much.

Code:
. sysuse auto
(1978 Automobile Data)

. egen price2=cut(price), group(5)

. tabulate price2

     price2 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         14       18.92       18.92
          1 |         15       20.27       39.19
          2 |         15       20.27       59.46
          3 |         15       20.27       79.73
          4 |         15       20.27      100.00
------------+-----------------------------------
      Total |         74      100.00

. xtile price3=price, n(5)

. tabulate price3

5 quantiles |
   of price |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         15       20.27       20.27
          2 |         15       20.27       40.54
          3 |         15       20.27       60.81
          4 |         15       20.27       81.08
          5 |         14       18.92      100.00
------------+-----------------------------------
      Total |         74      100.00

. egen mpg2=cut(mpg), group(5)

. tabulate mpg2

       mpg2 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         14       18.92       18.92
          1 |         13       17.57       36.49
          2 |         16       21.62       58.11
          3 |         12       16.22       74.32
          4 |         19       25.68      100.00
------------+-----------------------------------
      Total |         74      100.00

. xtile mpg3=mpg, n(5)

. tabulate mpg3

5 quantiles |
     of mpg |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         18       24.32       24.32
          2 |         17       22.97       47.30
          3 |         13       17.57       64.86
          4 |         12       16.22       81.08
          5 |         14       18.92      100.00
------------+-----------------------------------
      Total |         74      100.00

.