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: Sum up different values/inputs from different issues in a new variable


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Sum up different values/inputs from different issues in a new variable
Date   Wed, 10 Apr 2013 15:29:17 +0200

On Wed, Apr 10, 2013 at 3:05 PM, Abdullah Uenal wrote:
> What I have to do here is the following:
> 1) Take the issue 31532 from v1, sum up the v116 value of each input of
> v115.
> 2) Build a new variable (e.g. v300) for each v115 and sum up v116 according
> to the input (e.g. otype_t1) of v115.
>
> As an example, the following should demonstrate:
> v1      v300 (o_t3 sum of v116)         v301 (o_t3 sum of v117)
> 31712   5.9                             25.39

*------------------ begin example ------------------
// input the example data
clear all
input v1     str5 v115  v116   v117
      31532  "o_t1"     1.5    0.16
      31532  "o_t5"     2.0    0.87
      31532  "o_t9"     2.3    4.94
      31712  "o_t3"     4.5    2.30
      31712  "o_t1"     5.5    1.09
      31712  "o_t3"     1.4    23.09
      31712  "o_t8"     4.5    1.29
      31809  "o_t14"    4.6    1.34
      31809  "o_t1"     2.3    1.98
end

// compute the sums
bys v1    : egen v300 = total(v116)
bys v115 : egen v301 = total(v117)

// display the results
sort v1 v115
list, sepby(v1)
*------------------- end example -------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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