Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: st: Two identical observations except one variable = sum up this variable and drop one observation
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: Re: st: Two identical observations except one variable = sum up this variable and drop one observation
Date
Sun, 19 Jan 2014 18:54:41 +0000
It would do so, but for future reference, note another way to do it
collapse (sum) newshares, by(PERMNO date Price)
(as also suggested by Bret Howrey)
Nick
[email protected]
On 19 January 2014 18:47, miriam geringer <[email protected]> wrote:
> Thanks! This worked fine for me :)
>
> 2014/1/19 Red Owl <[email protected]>:
>> Miriam,
>>
>> Try this:
>>
>> egen newshares = total(Shares), by(PERMNO date Price)
>> bysort PERMNO date Price newshares: keep if _n==_N
>> drop Shares
>>
>>
>> Red Owl
>> [email protected]
>>
>>
>>> miriam geringer <[email protected]> wrote:
>>>
>>> This is how it looks:
>>> PERMNO date Price Shares offered
>>> 123456 1 5 8
>>> 123456 1 5 6
>>>
>>> This is how it should look like:
>>> PERMNO date Price Shares offered
>>> 123456 1 5 14
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>> * http://www.ats.ucla.edu/stat/stata/
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/