LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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??????????
In-Reply-To:  <941871A13165C2418EC144ACB212BDB0BEB503@dshsmxoly1504g.dshs.wa.lcl>
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.)

data class; set sashelp.class; run;

proc sql; delete from class where sex='M'; quit;

*does not work; DATA Work.LastObs; set class nobs=Nobs point=nobs; output; stop; run;

*works; data two; set class end=last; if last then output; run;

-Joe

On Tue, Oct 20, 2009 at 11:56 AM, Nordlund, Dan (DSHS/RDA) < NordlDJ@dshs.wa.gov> wrote:

> > -----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. > > > > > <<<snip>>> > > Ray, > > 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 > last > observation). > 3. stop is needed to keep the datastep from looping forever. > */ > data two; > set one nobs=number_of_obs point= number_of_obs; > output; > stop; > run; > > Hope this is helpful, > > Dan > > Daniel J. Nordlund > Washington State Department of Social and Health Services > Planning, Performance, and Accountability > Research and Data Analysis Division > Olympia, WA 98504-5204 >


Back to: Top of message | Previous page | Main SAS-L page