Bookmark and Share

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

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

st: RE: percentage format

From   "Harry Comber" <>
To   <>
Subject   st: RE: percentage format
Date   Thu, 10 Feb 2011 09:23:11 -0000

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.

Dr. Harry Comber, Director
National Cancer Registry (
Building 6800
Cork Airport Business Park
Kinsale Road
Tel  +353 21 4318014
Fax +353 21 4318016
The contents of this email are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorised designee, you may not copy or use it, or
disclose it to anyone else. If you have received it in error please
notify us immediately and then destroy it. The NCRI does not guarantee
the security of any information electronically transmitted and is not
liable if the information contained in this communication is not a
proper and complete record of the message as transmitted by the sender
or for any delay in its receipt.
-----Original Message-----
[] On Behalf Of Nick Cox
Sent: Wednesday, February 09, 2011 5:11 PM
To: ''
Subject: st: RE: RE: percentage format

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. 


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

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index