Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: Re: st: RE: reshaping a cross table on several indicators


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: Re: st: RE: reshaping a cross table on several indicators
Date   Fri, 19 Jan 2007 12:40:07 +0000

A typo of mine has misled you. Sorry about that.
For your data my recipe is

bys cat year: egen vara = sum(w)
by cat year:  egen varb = mean(wcrvd)
by cat year:  egen varc = mean(wgnrl)
gen tag=tag(cat year)
list cat year var? if tag

Nick
[email protected]

FUKUGAWA, N

based on your suggestion, i obtained a table as follows.

. bys cat year:egen vara=sum(w)
. by cat year:egen varb=mean(wcrvd)
. by cat year:egen varc=mean(wgnrl)
(180 missing values generated)
. egen tag=tag(vara varb varc year)
. list cat year var? if tag

table 1
        |       cat      year       vara       varb       varc |
  5656. |     abc        1995   178.0542   .2636083   .0556201 |
  6283. |     abc        1996   199.1647   .1246219    .031172 |
  6984. |     abc        1997   156.1064   .0312281   .0098527 |
  7569. |     xyz        1995   4.485714   .1666667          0 |

one problem is that table 1 does not allow a line with missing
values. as shown in table 2, cat xyz provides information on
1996 and 1997 but table 1 omits the lines of 1996 and 1997
because they include missing value cells.
each "cat" needs to have the same number of lines.

table 2
. table cat year,c(sum w mean wcrvd mean wgnrl) m f(%5.2f)

     cat  |   1995   1996   1997
----------+---------------------
    abc   | 178.05 199.16 156.11
          |   0.26   0.12   0.03
          |   0.06   0.03   0.01
          |
    xyz   |   4.49   1.04   1.00
          |   0.17   0.00   0.00
          |   0.00      .      .

how can i create table 3?

table 3
        |       cat      year       vara       varb       varc |
  5656. |     abc        1995   178.0542   .2636083   .0556201 |
  6283. |     abc        1996   199.1647   .1246219    .031172 |
  6984. |     abc        1997   156.1064   .0312281   .0098527 |
  7569. |     xyz        1995   4.485714   .1666667          0 |
     .  |     xyz        1996   1.04       0.00        .       |
      . |     xyz        1997   1.00       0.00        .       |

thank you in advance.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index