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: How to agreggate some specific observation to replace in another observation


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: How to agreggate some specific observation to replace in another observation
Date   Wed, 21 Aug 2013 09:27:43 +0100

Sorry, but this strikes me as a bad idea for Stata. You want to
sprinkle your variable with subtotals. The effect would just be to
introduce double counting and to render the variable useless for
virtually any other analysis unless you excluded those observations
from all subsequent commands.

Assuming that there are no other variables, what I suggest rather is
to delete observations designated for subtotals. I guess -NACE- is a
string variable in which case

drop if strpos(NACE, "_")
destring NACE, replace

Then you are interested in looking at the distribution of -NACE- for
which there are many possible tabulation and graph commands.

Nick
[email protected]


On 21 August 2013 08:51, leila Peltier <[email protected]> wrote:
> Dear Stata users,
>
> As I entitled my message I want to replace one observation with the
> SUM of some other specific obseration in the best and efficient way.
> My original  data are :
> VAR1        NACE
>                  16_18
>                      16
> 281.1            17
> 112               18
>                      19
> 423.4             20
> .1                   21
>                    22_23
> 1713.9            22
> 702.1              23
>                     24_25
> 2632.3             24
> 814.5               25
> 246.5               26
> 204.8               27
> 889.2               28
>                      29_30
> 109.7               29
> 1.6                   30
>                               .... and so on
>
> And I want to have :
>
> VAR1        NACE
>  393.1         16_18
>                      16
> 281.1            17
> 112               18
>                      19
> 423.4             20
> .1                   21
>  2416           22_23
> 1713.9            22
> 702.1              23
>  3446.8         24_25
> 2632.3             24
> 814.5               25
> 246.5               26
> 204.8               27
> 889.2               28
>  111.3            29_30
> 109.7               29
> 1.6                   30
>
> so for example 393.1 (NACE=16_18) is the sum of VAR1 if
> NACE==16&NACE==17&NACE==18
*
*   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