Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Summing by group of variables


From   "Jeremy Miles" <[email protected]>
To   [email protected]
Subject   Re: st: Summing by group of variables
Date   Mon, 23 Apr 2007 18:53:06 -0700

The command you used is going to sum by the rows.  You need to use
collapse.  I didn't understand enough about your problem to know
exactly what command to do, but try :

-help collapse-

And it should be reasonably straightforward.

Jeremy


On 23/04/07, Leonor Saravia <[email protected]> wrote:
Hello,

I would like to sum the variable "tax" by "year" (2001-2004) and
"industry" (between 31 and 39) if the variable region (between 1 and
13) satisfies some conditions, like: region<=4; region==5 & 6 & 7 & 13
 and if region==8 & 9 &10 & 11 & 12. This way I can create a new
variable: "zones", which is the sum of "tax" payed in an "industry" X
in the "year" 200X considering the range of regions defined before.
[snip]

bysort year industry: egen tax_zones=sum(tax), by(industry ano) if
region==5 & region==6 & region==7 & region==13

But it didn't work. Please, do you know how can I do this???


--
Jeremy Miles
Learning statistics blog: www.jeremymiles.co.uk/learningstats
Psychology Research Methods Wiki: www.researchmethodsinpsychology.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index