Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <n.j.cox@durham.ac.uk> |
To | "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: RE: Item set in one Graph and one Tab |
Date | Fri, 15 Jun 2012 13:33:57 +0100 |
-tabm- is a convenience command that temporarily restructures the data: it maps several variables to one, provides a cross-tabulation of original variables and values, and then returns the dataset to where it was. So, a direct consequence of what it does is that nothing much is left behind of consequence. But once you have -reshape-d, as is needed for the graphics, you can use any tabulation command on the equivalent results that works with what you want. -estpost- and -esttab- are user-written commands. Please remember the permanent and longstanding request to explain where user-written commands that you refer to come from. Nick n.j.cox@durham.ac.uk Jörg Eulenberger Thanks a lot Nick, it works fine. But how can i put the tabm-results automatic (syntax) to a rtf-file? tabm dosn't work with estpost and esttab. Am 15.06.2012 12:09, schrieb Nick Cox: > For tabulation, see (e.g.) -tabm- from -tab_chi- (SSC). > > . tabm q? > > | values > variable | aaa bbb ccc | Total > -----------+---------------------------------+---------- > label1 | 1 1 2 | 4 > label2 | 0 1 3 | 4 > label3 | 2 1 1 | 4 > label4 | 1 1 2 | 4 > -----------+---------------------------------+---------- > Total | 4 4 8 | 16 > > > -tabm- is a wrapper for -tabulate-, e.g. -tabm q?, row nofreq-. > > For graphing, I would -reshape- first and then use -catplot- (SSC). > > > . l > > +-----------------------+ > | q1 q2 q3 q4 | > |-----------------------| > 1. | aaa bbb aaa ccc | > 2. | bbb ccc aaa bbb | > 3. | ccc ccc bbb aaa | > 4. | ccc ccc ccc ccc | > +-----------------------+ > > . gen id = _n > > . reshape long q, i(id) > (note: j = 1 2 3 4) > > Data wide -> long > ----------------------------------------------------------------------------- > Number of obs. 4 -> 16 > Number of variables 5 -> 3 > j variable (4 values) -> _j > xij variables: > q1 q2 ... q4 -> q > ----------------------------------------------------------------------------- > > . rename (_j q) (question answer) > > . l > > +------------------------+ > | id question answer | > |------------------------| > 1. | 1 1 aaa | > 2. | 1 2 bbb | > 3. | 1 3 aaa | > 4. | 1 4 ccc | > 5. | 2 1 bbb | > |------------------------| > 6. | 2 2 ccc | > 7. | 2 3 aaa | > 8. | 2 4 bbb | > 9. | 3 1 ccc | > 10. | 3 2 ccc | > |------------------------| > 11. | 3 3 bbb | > 12. | 3 4 aaa | > 13. | 4 1 ccc | > 14. | 4 2 ccc | > 15. | 4 3 ccc | > |------------------------| > 16. | 4 4 ccc | > +------------------------+ > > . catplot answer question , percent(question) asyvars stack > > Nick > n.j.cox@durham.ac.uk > > Jörg Eulenberger > > I have a dataset like this: > > clear > input q1 q2 q3 q4 > 1 2 1 3 > 2 3 1 2 > 3 3 2 1 > 3 3 3 3 > end > > label var q1 "label1" > label var q2 "label2" > label var q3 "label3" > label var q4 "label4" > label define lab 1"aaa" 2"bbb" 3"ccc" > label value q1 lab > label value q2 lab > label value q3 lab > label value q4 lab > > now i want to create a table like this (to use with estpost): > > > aaa bbb ccc > label1 10% 80% 10% > label2 30% 20% 50% > label3 90% 5% 5% > label4 25% 25% 50% > > and a bar graph like this: > > http://www.survey-design.com.au/graphs/catplot3.png > > Is there a easy way to do 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/