Consider -groups- from SSC. (There was some discussion in
SJ-3-4 pr0011 . . . . . . . . Speaking Stata: Problems with tables,
Part II
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N.
J. Cox
Q4/03 SJ 3(4):420--439 (no
commands)
reviews three user-written commands (tabcount, makematrix,
and groups) as different approaches to tabulation problems
which is accessible to all under the Stata Journal's moving window.)
Some examples follow my signature.
Nick
[email protected]
. sysuse auto
(1978 Automobile Data)
. groups rep78, show(p)
+-----------------+
| rep78 Percent |
|-----------------|
| 1 2.90 |
| 2 11.59 |
| 3 43.48 |
| 4 26.09 |
| 5 15.94 |
+-----------------+
. groups rep78, show(p) showhead(%)
+---------------+
| rep78 % |
|---------------|
| 1 2.90 |
| 2 11.59 |
| 3 43.48 |
| 4 26.09 |
| 5 15.94 |
+---------------+
. groups rep78 if foreign, show(p) showhead(%)
+---------------+
| rep78 % |
|---------------|
| 3 14.29 |
| 4 42.86 |
| 5 42.86 |
+---------------+
kokootchke
I have a data set that contains bonds issued by a given country at
different points in time, with information about each bond. For
instance, one observation would look like:
country issuedate year issuer maturity yield currency amount
Mexico 09May98 1998 BXN 10 8.34 USD 250
I need to create lots of tables with summary statistics such as:
table country, c(m yield)
However, one type of table I don't know how to create quickly is one
with relative frequencies (and I'm always angry with the -table- command
because it doesn't seem to allow for tables of relative frequencies,
unlike -tab-... but I don't like -tab-!). What I want is a table that
gives me the percentage of bonds (observations) within a given country
that have maturities greater than, say, 3 years. So, I wish there was a
command that looked like:
table country, c(relfreq), if maturity>= 3
and produce a table like:
Argentina 26.7%
Brazil 37.8%
Mexico 49.3%
Zimbabwe 17.5%
...
I know that
table country if maturity>= 3
will give me the # of bonds (absolute frequency) that meet the condition
(maturity>= 3)... but I want this number in percentage terms.
Is there any easy way of doing this?
*
* 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/