Statalist


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

st: RE: More than 2 arguments for by


From   "Martin Weiss" <martin.weiss@uni-tuebingen.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: More than 2 arguments for by
Date   Tue, 16 Sep 2008 11:31:57 +0200

Well, the syntax diagram for -by- allows a varlist

******************
sysuse auto, clear
by foreign rep78, sort: summarize price
g t=price>10000
ta t
by foreign rep78 t, sort: summarize price
g r=gear>3
ta r
by foreign rep78 t r, sort: summarize price
by foreign rep78 t r, sort:keep if _n==_N
*******************



HTH
Martin




-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Ashim Kapoor
Sent: Tuesday, September 16, 2008 11:21 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: More than 2 arguments for by

Hello everyone:

I want to do the following :

sort year state cnum votes

by year stata cnum votes : keep if _n==_N

That way I get the guy with the max no of votes.

Now when I do this for 1 or 2 arguments for by then it works, but not
for 4 arguments I have . Does by have a limit on how many arguments it
can have ?

I read -help by- and that does mention using by in the following
fashion : -- > by year ( state) . Do I need to put in brackets for the
other arguments?

Could someone please clarify?

Thank you,
Ashim.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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