Statalist


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

Re: st: Format and Export(Excel) of 3-way table results


From   Nick Cox <n.j.cox@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Format and Export(Excel) of 3-way table results
Date   Tue, 04 Aug 2009 10:21:49 -0500

Alexandra got some excellent advice from Roy Wada. I have some further suggestions. I really can't advise on how best to use Excel.

Alexandra has three variables,
state
year
status

I am not clear what -state- is for real. Let's imagine that it means the 50 states of the United States. -year- takes on 41 distinct values and -status- 2 distinct values. In this thought experiment there are 50 * 41 * 2 cells or 4100 cells.

Even small tricks of fine tuning can not make effective display of 4100 cells at all easy.

An old device is to fall back on a list

state status year frequency

which is possible with -groups- from SSC.

Another old device is to plot the data, not tabulate it.

Nick

Green Alexandra <alexandra.b.green@gmail.com> wrote on 30 Jul 2009:

I am trying to create a table to follow the trends in some over time.
In this case, I have monthly data on rainfall by state over time, 1960
to 2000. Status is a dummy that tracks  if rainfall in that month is
above (A) or below (B) average for that month over time. So I want the
table to show frequencies for the number of months that are A and B,
over the sample period.

2 Questions:
1. using tab3way seems to give me what I wish for (see partial output
below), but since I have to cover a space of 40 years over all the
states, the output wraps around the result window and is very
unsightly.
=> Is there a way for me to ask stata to export the results, so I can
recreate a table that's more reader-friendly say in Excel?

. tab3way  state status year
Table entries are cell frequencies
Missing categories ignored
----------------------------------------------------------------------------
          |                   year and status
          | -- 1990 --    -- 1991 --    -- 1992 --    -- 1993 --
  state |   A     B      A     B        A     B        A     B
----------+----------------------------------------------------------------
        1 |    1     2             3         1     2       1     2
        2 |    1     1             1                         1
----------------------------------------------------------------------------


2. Is there a way to have stata output frequencies for months that are
above average and months that are below average for the same state on
2 rows in an alternating fashion (such as in the "wanted" result)?
Wanted:

----------------------------------------------------------------------------
          |                   year and status
          | -- 1990 --    -- 1991 --    -- 1992 --    -- 1993 --
  state |   A     B      A     B        A     B        A     B
----------+----------------------------------------------------------------
        1 |    1             3               2                2
           |           2             3               2                2
        2 |    1             0               0                1
           |           1             1               0                1
----------------------------------------------------------------------------


*
*   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   |   What's new   |   Site index