Nick is correct. I overlooked this crucial
detail! The parentheses only make sense
in some context like
. by <varlist> ( <varlist2> ) : ...
so that
. by (<varlist2>) : ...
is meaningless to Stata, irrespective
of sort order.
I think it remains true that something
like -contract- is your best approach
to produce another dataset of frequencies.
Thanks to those who refrained from referring
me to the tutorial on -by:- in SJ 2(1) 2002.
Nick Winter
> > > Or..
> > > why does the following code not work?
> > >
> > > . by (var1 var2): egen freq=count(var3)
> > >
> > > I want to count the number of occurences (var3) for each
> > > year for each
> > > country. how do i save this reorganized result in a .dta file?
>
> You need to omit the parentheses:
>
> . by var1 var2: egen freq=count(var3)
>
> (And be sure you've previously sorted on var1 var2).
*
* 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/