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: RE: percentage format


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: RE: percentage format
Date   Thu, 10 Feb 2011 10:15:41 +0000

One view on this, whether or not it is the StataCorp view, is that

1. it is easy enough to specify in a variable label that results are
"%", "percent", "percentage", "Pct", etc. and through that users have
complete control over what is shown.

2. it is easy enough to use a -display- statement to show something
similar for individual summary measures.

3. "%" being displayed against every value in a row, column or table
is busy, repetitive and a minor insult to the reader.

I guess there is room for disagreement, especially on #3.

Nick

On Thu, Feb 10, 2011 at 9:23 AM, Harry Comber <[email protected]> wrote:
> Thanks for the information. My apologies for an error in the original
> question, where I should have written "mean" and not "sum", as pointed
> out by Caleb, and as I realised after I posted the question. As I said,
> I knew there were workarounds, but it would be more convenient not to
> have to create more variables and also have to add in "%" signs later.
> If there is no such format, I'll work out something else.

Nick Cox

> I was thinking that you wanted an explicit "%" sign. Perhaps so, perhaps
> not. If you don't, then as Caleb advised it is often easy enough.

Nick Cox

> There is no such format that I know of. I can't think of a reason for
> not documenting it as others would want it too for your reasons.
>
> In some circumstances you can mimic this by creating a string variable
> such as below:
>
> . sysuse auto
>
> . su weight
>
>    Variable |       Obs        Mean    Std. Dev.       Min        Max
> -------------+--------------------------------------------------------
>      weight |        74    3019.459    777.1936       1760       4840
>
> . gen sweight = string(100 * weight/r(mean), "%8.2f") + "%"
>
> . l sweight in 1/10
>
>     +---------+
>     | sweight |
>     |---------|
>  1. |  97.04% |
>  2. | 110.95% |
>  3. |  87.43% |
>  4. | 107.64% |
>  5. | 135.12% |
>     |---------|
>  6. | 121.54% |
>  7. |  73.85% |
>  8. | 108.63% |
>  9. | 128.50% |
>  10. | 112.60% |
>     +---------+
>
> I am not clear that this helps you with -table-. Some tables are easier
> to mimic than others. Two- and higher-dimensional tables are naturally
> more difficult.
>
> Nick
> [email protected]
>
> Harry Comber
>
> Is there an extension of the Stata -format- command which produces
> percentage formats? I would like to use this in the -table- command as
> in (hypothetically):
>        table sex agegroup, c(sum surgery) format(%2.1p)
> If "surgery" is either 0 (no) or 1 (yes) for each individual, this would
> give a table of % having surgery. I know there are other ways of doing
> this but the tables are typically much more complex than the example
> given and it would be very useful to me if I could format the output as
> percentages.

*
*   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