Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Display one observation


From   "Cohen, Elan" <cohened@upmc.edu>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Display one observation
Date   Wed, 15 Sep 2010 14:18:27 -0400

bys year (cusum): gen last = _n==_N
list year cusum if last

- Elan
 

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu 
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of 
> Skipper Seabold
> Sent: Wednesday, September 15, 2010 14:07
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: Display one observation
> 
> On Wed, Sep 15, 2010 at 2:02 PM, Dimitriy V. Masterov
> <dvmaster@gmail.com> wrote:
> > If your sums is monotonic, as it appears to be, I think 
> this should work:
> >
> 
> It is.
> 
> > bys year: egen maxcs=max(cusum)
> >
> > I get this:
> >
> > year    cusum   maxcs
> > 2000    2       8
> > 2000    4       8
> > 2000    6       8
> > 2000    8       8
> > 2000            8
> > 2000            8
> > 2001    5       12
> > 2001            12
> > 2001    6       12
> > 2001    12      12
> >
> >
> 
> Thanks, but I don't want to create a new variable.  I should've said,
> I'd ideally like to write a loop and then have something that looks
> like
> 
> 8
> 12
> 
> spit back to me at the prompt.  Right now I have to browse by what I
> need and copy and paste the last observation, which is rather tedious.
> 
> Skipper
> 
> *
> *   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   |   Site index