Statalist The Stata Listserver


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

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


From   "FUKUGAWA, N." <[email protected]>
To   [email protected]
Subject   Re: st: RE: reshaping a cross table on several indicators
Date   Fri, 19 Jan 2007 15:35:03 +0900

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.
---
FUKUGAWA Nobuya, Ph.D.
[email protected]


-------- Original Message  --------
Subject: st: RE: reshaping a cross table on several indicators
From: Nick Cox <[email protected]>
To: [email protected]
Date: Thu Jan 18 2007 23:00:31 GMT+0900

> bysort cat year : egen meanx = mean(x)
> by cat year : egen meany = mean(y)
> by cat year : egen meanz = mean(z)
> egen tag = tag(mean year) 
> list cat year mean? if tag 
> 
> Nick 
> [email protected] 
> 
> FUKUGAWA, N.
> 
>> i made cross table on indicators x, y, and z.
>>
>> table cat year,c(mean x mean y sum z) m f(%5.2f)
>>
>> 	year
>> cat	1983	1984	1985
>> a	1	2	3
>> 	4	5	6	
>> 	.	.	.	
>> b	10	20	30
>> 	40	50	60	
>> 	70	80	90	
>> c	100	200	300
>> 	.	.	.
>> 	700	800	900
>>
>> how can i convert this table as follows?
>>
>> cat	year	x	y	z
>> a	1983	1	4	.
>> 	1984	2	5	.
>> 	1985	3	6	.
>> b	1983	10	40	70	
>> 	1984	20	50	80
>> 	1985	30	60	90
>> c	1983	100	.	700
>> 	1984	200	.	800
>> 	1985	300	.	900
> *
> *   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/
> 
*
*   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