[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: Re: st: how to creating a variable recording the sum of anothervariable by group in panel data?
What is the difference between
(a) industry year
(b) industry, year
Answer: (a) qualifies as a varlist, so long as
you have variables -industry- and -year- in your dataset.
(b) doesn't, even when that is so. It contains two variable names
separated by a comma, but that is _not_ a varlist to Stata.
The syntax diagram for -egen, group()- explains that its
-by()- option takes a varlist. (a) is fine; (b) is a syntax
So why not? Explained like that, Stata appears very picky
indeed. To understand why Stata must be strict here,
recall that many commands have syntax diagrams that
include options, and the way to signal that a variable list
stops and a list of options begins is to use a comma
as separator. Otherwise you and Stata could get into
no end of tangles with option names that were like
variable names, and vice versa.
But, surely, you might say, Stata is not expecting
any options _inside_ options? Have a look at [G] for
an answer to that.
I have just found that I can do this:
egen alloutput=total(output), by(industry year)
I did try this before but I put it as by(industry, year) and it didn't work.
* For searches and help try: