Rod, this works for me
. sum p, d
Price
-------------------------------------------------------------
Percentiles Smallest
1% 3291 3291
5% 3748 3299
10% 3895 3667 Obs 74
25% 4195 3748 Sum of Wgt. 74
50% 5006.5 Mean 6165.257
Largest Std. Dev. 2949.496
75% 6342 13466
90% 11385 13594 Variance 8699526
95% 13466 14500 Skewness 1.653434
99% 15906 15906 Kurtosis 4.819188
. list make price if price == `r(p75)'
make price
23. Dodge St. Regis 6,342
**
You may or may not use ur own macro. If u use ur own macro, the
after sum p, d, you could
local p75 = r(p75) (I notice u missed this step)
and then list
list make price if price == `p75'
Hope this helps
Ronnie
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Rod Hunter
Sent: 3. februar 2003 20:34
To: [email protected]
Subject: Re: st: RE: Percentiles: Identify of smallest observation
closet to percentile value
Thanks Nick and Ronnie.
I still don't appear to be out of the woods.
1.
I applied Nick's procedure to my example:
. centile var1 , c(75)
--------------------------------------------------------------------
-- Binom. Interp. --
Variable Obs Percentile Centile [95% Conf. Interval]
var1 4 75 9.75 7.45 10*
* Lower (upper) confidence limit held at minimum (maximum) of sample
-----------------------------------------------------------
. ret li
------------------------------------------------
scalars:
r(n_cent) = 1
r(N) = 4
r(ub_1) = 10
r(lb_1) = 7.450000000008672
r(c_1) = 9.75
macros:
r(centiles) : "75"
-------------------------------------------------
. list var1 if var1 == `r(c_1)'
-----------------------------------------------
var1
.
-----------------------------------------------
This does not give me the identity nor value of the largest observation
within the percentage of the observations included by the 75th percentile.
2.
I tried Ronnie's approach:
. sum var1, d
-------------------------------------------
var1
Percentiles Smallest
1% 7 7
5% 7 8
10% 7 9 Obs 4
25% 7.5 10 Sum of Wgt. 4
50% 8.5 Mean 8.5
Largest Std. Dev. 1.290994
75% 9.5 7
90% 10 8 Variance 1.666667
95% 10 9 Skewness 0
99% 10 10 Kurtosis 1.64
---------------------------------------------------
. local macro*
. list var1 if var1 == `p75'
-------------------------------------------------
var1
-------------------------------------------------
3.
This is what I have been using:
. _pctile var1,p(75)
. gen var1_p75=r(r1)
. tabstat var1 if var1==var1_p75, stat(max)
-------------------------------------
no observations
-------------------------------------
alternatively:
. list var1 if var1==var1_p75
---------------------------------------
var1
---------------------------------------
Any further suggestions?
Regards,
Rod Hunter
Nick Cox wrote:
> Rod Hunter
>
>>A simple eg. will suffice.
>>
>>Obs. Var1
>>----------
>>1 10
>>2 9
>>3 8
>>4 7
>>-----------
>>
>>I would like Stata to tell me the value of the observation
>>that is at or
>> below the 75th percentile point, and to yield the identity (or
>>identities) of the observation(s).
>
>
> I'll change your example. I don't know about "below". ~ 75% are
> below; do you what them all?
>
> . use auto
> . centile rep78 , c(75)
>
> -- Binom.
> Interp. --
> Variable | Obs Percentile Centile [95% Conf.
> Interval]
> -------------+--------------------------------------------------------
> -----
> rep78 | 69 75 4 4
> 5
>
> . ret li
>
> scalars:
> r(n_cent) = 1
> r(N) = 69
> r(ub_1) = 5
> r(lb_1) = 4
> r(c_1) = 4
>
> macros:
> r(centiles) : "75"
>
> . list rep78 if rep78 == `r(c_1)'
>
> +-------+
> | rep78 |
> |-------|
> 5. | 4 |
> 15. | 4 |
> 24. | 4 |
> 29. | 4 |
> 30. | 4 |
> |-------|
> 33. | 4 |
> 35. | 4 |
> 38. | 4 |
> 47. | 4 |
> 55. | 4 |
> |-------|
> 56. | 4 |
> 58. | 4 |
> 59. | 4 |
> 62. | 4 |
> 63. | 4 |
> |-------|
> 70. | 4 |
> 72. | 4 |
> 73. | 4 |
> +-------+
> Nick
> [email protected]
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
>
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/