Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Item set in one Graph and one Tab


From   Jörg Eulenberger <j.eulenberger@web.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Item set in one Graph and one Tab
Date   Fri, 15 Jun 2012 12:55:05 +0200

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.
Thanks,
Jörg





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/
>


*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index