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]

From |
Phil Clayton <[email protected]> |

To |
[email protected] |

Subject |
Re: st: How does Stata calculate percentiles? |

Date |
Sun, 24 Oct 2010 16:42:41 +1100 |

One way to do it would be to obtain the centile using the -centile- command, then -recode- the variable to create the indicator variable. Example: sysuse auto centile price, centile(33) local cutpoint=r(c_1) recode price (min/`cutpoint'=0) (`cutpoint'/max=1), gen(pricecat) If you wanted the indicator variable to be 1 if the variable is >= the cutpoint (as opposed to >), swap the two recoding rules (once one rule is matched, the subsequent rules are ignored). See the manual for -centile- to see how it's calculated. It's pretty standard. With regards to "su varname, d", see -help summarize- and the manual for -summarize- Phil On 24/10/2010, at 3:27 PM, Grace Jessie wrote: > Dear statalists, > I want to generate a new variable equaling 1 if the other variable is greater than its 100/3 percentile and 0 otherwise.How to get the 100/3th percentile of a variable? > And how does Stata calculate percentiles if the number of observations is odd or even? > Additionally, what does the output "smallest and largest" mean after "su varname,d"? > Thanks! > > Grace > * > * 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/ * * 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/

**Follow-Ups**:**RE: st: How does Stata calculate percentiles?***From:*Nick Cox <[email protected]>

**References**:**st: How does Stata calculate percentiles?***From:*Grace Jessie <[email protected]>

- Prev by Date:
**st: How does Stata calculate percentiles?** - Next by Date:
**Re: st: How to expand the data using set-variables** - Previous by thread:
**st: How does Stata calculate percentiles?** - Next by thread:
**RE: st: How does Stata calculate percentiles?** - Index(es):