Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Problem selecting data range within a variable


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Problem selecting data range within a variable
Date   Thu, 19 Jul 2012 11:15:52 +0100

Here are some simple idea:

. sysuse auto, clear
(1978 Automobile Data)

. xtile pq = price, nq(10)

. tab pq

         10 |
  quantiles |
   of price |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          8       10.81       10.81
          2 |          7        9.46       20.27
          3 |          8       10.81       31.08
          4 |          7        9.46       40.54
          5 |          7        9.46       50.00
          6 |          8       10.81       60.81
          7 |          7        9.46       70.27
          8 |          8       10.81       81.08
          9 |          7        9.46       90.54
         10 |          7        9.46      100.00
------------+-----------------------------------
      Total |         74      100.00

. tab pq if pq == 1 | pq == 10, su(weight)

         10 |
  quantiles |      Summary of Weight (lbs.)
   of price |        Mean   Std. Dev.       Freq.
------------+------------------------------------
          1 |    2,373.75   370.98084           8
         10 |   4,024.286   628.24775           7
------------+------------------------------------
      Total |       3,144   982.05906          15

Nick

On Thu, Jul 19, 2012 at 10:57 AM, WAREHAM H.M.
<[email protected]> wrote:
> I have some data and one of the variables I have put into deciles.  For an analysis I want to compare variables from the top 10% (decile 1) and the bottom 10% (decile 10) of the data but I can't work out how to get Stata to do that.
>
> I'm very new to Stata so the more simple the explanation the better.
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index