Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Problem selecting data range within a variable


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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.
<helen.wareham@durham.ac.uk> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index