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: recovering -table- output for programmatic use
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: recovering -table- output for programmatic use
Date
Mon, 6 Feb 2012 15:29:27 +0000
I am not so sure as you. The short answer is that -table- leaves nothing useful in memory. It is designed as a reporting command, not as an estimation or calculation command.
Besides, what would you expect to be available? Even simple -table- statements could generate several matrices' equivalent in output, and retrieving that would be a pain, however well it was ordered.
There's a much nicer answer. In essence, -table- is a wrapper for -collapse-. What you get shown by -table- is available by an equivalent -collapse-, or that's what it looks like from here.
For example,
. sysuse auto
(1978 Automobile Data)
. table for rep78, c(mean mpg sd mpg)
------------------------------------------------------------
| Repair Record 1978
Car type | 1 2 3 4 5
----------+-------------------------------------------------
Domestic | 21 19.125 19 18.4444 32
| 4.24264 3.758324 4.085622 4.585606 2.828427
|
Foreign | 23.3333 24.8889 26.3333
| 2.516612 2.713137 9.367497
------------------------------------------------------------
. collapse (mean)mean=mpg (sd)sd=mpg, by(for rep78)
. l
+--------------------------------------+
| rep78 foreign mean sd |
|--------------------------------------|
1. | 1 Domestic 21 4.24264 |
2. | 2 Domestic 19.125 3.75832 |
3. | 3 Domestic 19 4.08562 |
4. | 4 Domestic 18.4444 4.58561 |
5. | 5 Domestic 32 2.82843 |
|--------------------------------------|
6. | . Domestic 23.25 3.40343 |
7. | 3 Foreign 23.3333 2.51661 |
8. | 4 Foreign 24.8889 2.71314 |
9. | 5 Foreign 26.3333 9.3675 |
10. | . Foreign 14 . |
+--------------------------------------+
If that doesn't work for you, show the -table- commands you are using.
Nick
[email protected]
Charles Vellutini
This question has been asked before but I have not found the simple exact solution (that I am sure must exist). So here it is: how do we recover the output of a -table- command for programmatric use, ideally as a matrix? I am aware of the user-written -tabstatmat- command but that works only with -tabstat-.
*
* 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/