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: How to do fast easy Tables of totals and proportions imported to excel or word
From
Gasto Social Peru <[email protected]>
To
[email protected]
Subject
st: How to do fast easy Tables of totals and proportions imported to excel or word
Date
Thu, 1 Aug 2013 15:47:31 -0500
Dear Stata users,
I need some help on the following:
I want to create tables of TOTALS and PROPORTIONS of budget expenses
with respect to different categories. I am wondering if anyone knows
of how to create and export such tables to excel or word.
The commands for total and prop (total, prop) do not allow me to
export to excel and word. I need to produce several tables and do not
want to copy paste, all of them. Right now the only way to do so has
been by collapsing the data. But then I will need to do this 10 times
or more plus copy paste results. I wonder if there is an easy way to
do so.
See example below using price for budget:
sysuse auto
sum
* I want to get the totals of price for diferent type of categories,
in this case for foreign and trunk
. sum foreign trunk price
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
foreign | 74 .2972973 .4601885 0 1
trunk | 74 13.75676 4.277404 5 23
price | 74 6165.257 2949.496 3291 15906
.
. bysort foreign trunk: egen MONTOPRICE2 =total(price)
* Here the the variable MONTOPRICE2 is the total for price in each
categories (foreign, trunk)
.
. list foreign trunk price MONTOPRICE2
+--------------------------------------+
| foreign trunk price MONTOP~2 |
|--------------------------------------|
1. | Domestic 7 3,667 12773 |
2. | Domestic 7 4,934 12773 |
3. | Domestic 7 4,172 12773 |
4. | Domestic 8 3,984 10470 |
5. | Domestic 8 6,486 10470 |
|--------------------------------------|
6. | Domestic 9 4,389 11517 |
7. | Domestic 9 3,299 11517 |
8. | Domestic 9 3,829 11517 |
9. | Domestic 10 4,453 12835 |
10. | Domestic 10 4,187 12835 |
|--------------------------------------|
11. | Domestic 10 4,195 12835 |
12. | Domestic 11 4,647 17920 |
13. | Domestic 11 4,425 17920 |
14. | Domestic 11 4,749 17920 |
15. | Domestic 11 4,099 17920 |
..........
65. Foreign 12 9,735 16875
--------------------------------------
66. Foreign 12 7,140 16875
67. Foreign 14 5,899 30884
68. Foreign 14 12,990 30884
69. Foreign 14 11,995 30884
70. Foreign 15 9,690 19784
--------------------------------------
71. Foreign 15 4,697 19784
72. Foreign 15 5,397 19784
73. Foreign 16 6,850 11146
74. Foreign 16 4,296 11146
+--------------------------------------+
* I want to create many similar tables like this exportable to word
or excel, in this case I am adding up in two categories but I want to
add up with more or less.
. bysort foreign trunk: gen n =1 if _n==1
(48 missing values generated)
. list foreign trunk MONTOPRICE2 if n==1
+-----------------------------+
| foreign trunk MONTOP~2 |
|-----------------------------|
1. | Domestic 7 12773 |
4. | Domestic 8 10470 |
6. | Domestic 9 11517 |
9. | Domestic 10 12835 |
12. | Domestic 11 17920 |
|-----------------------------|
16. | Domestic 12 3799 |
17. | Domestic 13 28367 |
21. | Domestic 14 4181 |
22. | Domestic 15 17982 |
24. | Domestic 16 60478 |
|-----------------------------|
34. | Domestic 17 47639 |
42. | Domestic 18 13594 |
43. | Domestic 20 44419 |
49. | Domestic 21 12130 |
51. | Domestic 22 11497 |
|-----------------------------|
52. | Domestic 23 6165 |
53. | Foreign 5 4499 |
54. | Foreign 6 6229 |
55. | Foreign 8 17797 |
58. | Foreign 9 3748 |
|-----------------------------|
59. | Foreign 10 9694 |
61. | Foreign 11 19807 |
65. | Foreign 12 16875 |
67. | Foreign 14 30884 |
70. | Foreign 15 19784 |
|-----------------------------|
73. | Foreign 16 11146 |
+-----------------------------+
Or I do collapse:
collapse price, by (trunk foreign)
collapse price by ( foreign)
etc...
thanks
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/