Statalist The Stata Listserver


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


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: Re: st: how to creating a variable recording the sum of anothervariable by group in panel data?
Date   Tue, 22 May 2007 22:13:53 +0100

What is the difference between

(a) industry year

and

(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
disaster.

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.

Nick
[email protected]

natalie chan

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