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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Sum variable over all countries excluding observations from nth country


From   sanjesh kumar <kumarsanjesh2004@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Sum variable over all countries excluding observations from nth country
Date   Sat, 1 Sep 2012 08:26:11 -0700 (PDT)

Thank you Olivia. 

i think this works

----- Original Message -----
> From: Olivia Bacha <oliviabacha@gmail.com>
> To: statalist@hsphsun2.harvard.edu
> Cc: 
> Sent: Sunday, 2 September 2012 1:10 AM
> Subject: Re: st: Sum variable over all countries excluding observations from nth country
> 
>T ry this:
> 
> egen sum_x=total(x)
> gen Sum=sum_x - x
> 
> Best,
> 
> 2012/9/1 sanjesh kumar <kumarsanjesh2004@yahoo.com>:
>>  Dear Statalisters
>> 
>>  i would like to seek help from you guys. i have a variable which varies 
> across countries over time. say i have 100 countries in year 2000 for a variable 
> X. i want to  create a sum of variable X over all countries leaving the 
> observation of nth country. this i need to do for each country. for example i 
> have
>> 
>>  country                 year            x               Sum(x)
>>  Australia                2000          6                    16
>>  New Zealand         2000          4                    18
>>  United States         2000          8                    14
>>  UK                         2000          3                    19
>>  China                     2000          1                    21
>> 
>>  i would like to get a command which gives me the values in the last column. 
> for Australia the values in the last column is 16 (=4+8+3+1), for New Zealand it 
> is 18 (=6+8+3+1), for United States it is 14 (=6+4+3+1) and for other countries 
> it follows the same pattern. i would like to do this for all the countries in my 
> sample and for every year.
>> 
>> 
>>  thanks
>>  sanjesh
>> 
>>  *
>>  *   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/
> 
> *
> *   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/
> 

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