Statalist The Stata Listserver


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

st: Summing by group of variables


From   "Leonor Saravia" <[email protected]>
To   [email protected]
Subject   st: Summing by group of variables
Date   Mon, 23 Apr 2007 21:41:11 -0400

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.
I post part of my dataset below.

tax      year      industry  region

300     2001        31         1
230     2001        32          1
300     2002        31          2
110     2002        33          3
240     2003        31         4
260     2004        32         3
10       2004        33         13
300     2001        31         5
230     2001        32          6
300     2002        31          2
110     2002        33          7
240     2003        31         13
260     2004        32         8
10       2004        33         9
240     2003        31         7
260     2004        32         10
10       2004        33         2
240     2003        31         11
260     2004        32         12
10       2004        33         2

I've tryed using:

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

Thanks in advance!

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