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]
st: RE: RE: percentage format
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: RE: percentage format
Date
Wed, 9 Feb 2011 17:10:52 +0000
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
[email protected]
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/