Statalist The Stata Listserver


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

Re: st: RE: RE: Data management


From   Ulrich Kohler <kohler@wzb.eu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: RE: Data management
Date   Wed, 21 Mar 2007 19:42:05 +0100

Roy,Suryadipta wrote:
> Hi,
>
> I have a dataset of the following form and I am trying to
> generate the last two columns:
>
> id year	oid   did	dist  tvol   tsum     tshare1 tshare2
> 1 2000	1	2	5	1	6	0.17	0.2
> 1 2000	1	3	10	1	6	0.17	0.2
> 1 2000	1	4	15	1	6	0.17	0.2
> 1 2001	1	2	5	2	4	0.5	1
> 1 2001	1	3	10	2	4	0.5	1
> 1 2001	1	4	15	2	4	0.5	1
> 1 2002	1	2	5	3	17	0.18  0.21
> 1 2002	1	3	10	3	17	0.18  0.21
> 1 2002	1	4	15	3	17	0.18  0.21
> 2 2001	2	1	5	2	4	0.5	1
> 2 2001	2	3	4	2	4	0.5	1
> 2 2001	2	4	2	2	4	0.5	1
> 2 2002	2	1	5	4	17	0.24  0.31
> 2 2002	2	3	4	4	17	0.24  0.31
> 2 2002	2	4	2	4	17	0.24  0.31
> 4 2000	4	1	15	5	6	0.83	5
> 4 2000	4	2	2	5	6	0.83	5
> 4 2000	4	3	5	5	6	0.83	5
> 4 2001	4	1	15		4
> 4 2001	4	2	2		4
> 4 2001	4	3	5		4
> 4 2002	4	1	15	10	17	0.59  1.43
> 4 2002	4	2	2	10	17	0.59  1.43
> 4 2002	4	3	5	10	17	0.59  1.43

and added later on:

> I am sorry that the dataset that I wanted to create was
> accidentally sent before. I am trying to create the last
> two columns, where
>
> tsum for id 1 for year 2000=sum(tvol for all for
> year=2000),
> tshare1= tvol/tsum, and tshare2=tvol/(tsum-tvol).
>
> Thanking you all for your cooperation (not least my econ
> colleagues:) for their generous support).

What's wrong with

  gen tshare1 = tvol/tsum
  gen tshare2 = tvol/(tsum-tvol)






-- 
Ulrich Kohler
kohler@wzb.eu
030/25491-361
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index