Date: Tue, 20 Oct 2009 12:12:48 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: How to report last obs only??????????
Content-Type: text/plain; charset=ISO-8859-1
I assume all of you are noting that this assumes the dataset was created in
SAS and not operated on in some nefarious way that would change the number
or ordering of observations without SAS knowing, right... (Except Shiva,
his solution works fine.)
delete from class where sex='M';
*does not work;
set class nobs=Nobs point=nobs;
set class end=last;
if last then output;
On Tue, Oct 20, 2009 at 11:56 AM, Nordlund, Dan (DSHS/RDA) <
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ray
> > Sent: Tuesday, October 20, 2009 9:03 AM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Re: How to report last obs only??????????
> > Whooooooa!
> > I am just browsing to learn more SAS tips here but ...
> > Could y'all comment your code? My guess is that anyone who does not
> > already know how to get the last observation also does not know how
> > these pieces of code are actually working. Understanding THAT would
> > help even more.
> > "Teach a man to report the last obs
> > Feed him for a day
> > Teach him what the code actually means
> > Feed him for a lifetime"
> > or something like that.
> > I know. I know. ... RTFM.
> > Ray
> > On Oct 20, 8:20 am, Tom Abernathy <tom.aberna...@gmail.com> wrote:
> > > Whaaaaaaaaaaaaaa?
> > > Use a DO loop to set the last obs in a dataset?
> > > :)
> > >
> > > 3 data two;
> > > 4 set one nobs=nobs point=nobs;
> > > 5 output;
> > > 6 stop;
> > > 7 run;
> > >
> > > NOTE: The data set WORK.TWO has 1 observations and 1 variables.
> > >
> Here are some comments
> /*1. the nobs= option on the set statement places number of obs in the
> following variable (aptly named number_of_obs here)
> 2. the point= option says read the observation number held in the
> following variable (number_of_obs IS the observation number of the
> 3. stop is needed to keep the datastep from looping forever.
> data two;
> set one nobs=number_of_obs point= number_of_obs;
> Hope this is helpful,
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA 98504-5204