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 on April 23, and its replacement, statalist.org is already up and running.


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

st: Insert sum of column values by id as new observation


From   "Mike Kim" <kalisperos@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Insert sum of column values by id as new observation
Date   Wed, 22 Dec 2010 23:24:54 -0600

Hi All,

My data looks like the following and I would like to create sum of wk1ad
wk2ad... by id and insert as new observations.

id	wk1ad		wk2ad	 ...
1	10		10
1	20		10
2	10		20
2	10		20
2	20		10
3	10		20
.....

The resulting data I want to have is the following. How can I do this work
in Stata?

id	wk1ad		wk2ad	 ...
1	10		10
1	20		10
1	30		20   <- newly created obs
2	10		20
2	10		20
2	20		10
2	40		50   <- newly created obs
3	10		20   <- do not need to create obs
.....

Thank you in advance.
Mike.


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