Date: Mon, 30 Sep 2002 14:01:05 +0100
Reply-To: John Whittington <John.W@MEDISCIENCE.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: John Whittington <John.W@MEDISCIENCE.CO.UK>
Subject: Re: Last record in a dataset
In-Reply-To: <E17vK8t-0007SZ-00@coumxnn01.netbenefit.co.uk>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 15:57 28/09/02 +0000, Paul Dorfman wrote (in part):
>If it is a SAS data set, then the fastest way (for it avoids reading all
>records but the very last one) is
>
>data lastrec ;
> set A point = n nobs = n ;
> output ; *write last rec from A as 1-obs file ;
> put _all_ ; *dump last rec from A to the log ;
> stop ;
>run ;
Paul, presumably one problem with that, as Jack is always pointing out to
us, is that there are circumstances (albeit ones very rarely applicable to
me) in which NOBS does not return the correct value of the number of
observations. That being the case, unless one could somehow be certain
that those particular circumstances could _never_ be operative, it would
seem that one could not rely completely upon that code to read the last
observation.
I suppose one could write code (with appropriate error-trapping) which
deliberately attempted to read observations _beyond_ the end of the dataset
and then work backwards/fowards as necessary, using point=, in order to
identify the true 'last observation' - but unless the dataset concerned was
massive, it would probably be just as quick to read the whole thing!
Kind Regards,
John
----------------------------------------------------------------
Dr John Whittington, Voice: +44 (0) 1296 730225
Mediscience Services Fax: +44 (0) 1296 738893
Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk
Buckingham MK18 4EL, UK mediscience@compuserve.com
----------------------------------------------------------------
|