Bookmark and Share

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: st: summing and reshaping the data


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: summing and reshaping the data
Date   Tue, 11 Mar 2014 15:30:25 +0000

You are mixing two distinct issues here. Using the more modern name
(-egen, sum()- still works but has been undocumented since Stata 9 or
so)

egen total = total(workers), by (company)

necessarily produces repeated values for your data. But naturally
there are problems for which you wish to use just one of those values
for each company. -egen- also offers a solution for this

egen tag = tag(company)

after which -if tag- is sufficient to select just one value for each
distinct -company-.

Nick
[email protected]


On 11 March 2014 14:55, Sara Neto Machado <[email protected]> wrote:
> Dear all,
>
> company--workers----V1
> 10---------------6---------10
> 10---------------3---------10
> 10---------------1---------10
> 11---------------3----------3
> 15--------------10---------21
> 15--------------11---------21
> 18---------------5----------5
>
> What I pretend to do is to sum up the number of workers for each
> company but without any values repeating, namely, company numbers
> should not repeat. To do the sum I have computed this straigthforward
> comand:
>
> egen V1 = sum (workers), by (company)
>
> the latter generated the column V1 but I do not manage to find a way
> to not repeat the number of company and the V1 numbers that refer to
> the same company. For instance, company 10 continues to have 3
> separated lines saying the same total. How do you manage to this two
> simultaneous things? What is the most efficient way to not repeat
> number of company and the correspondent lines in the V1 column?
>
> thanks in advance for whom responds to this inquiry
> Regards,
> Sara
> *
> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index