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 (May 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 11 May 2009 05:56:19 -0400
Reply-To:   Søren Lassen <s.lassen@POST.TELE.DK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Søren Lassen <s.lassen@POST.TELE.DK>
Subject:   Re: First and Last Observations.
Comments:   To: Arthur Tabachneck <art297@NETSCAPE.NET>
Content-Type:   text/plain; charset=ISO-8859-1

Art, Do you mean faster in elapsed time, or in CPU time? On a PC, it may be the latter that is of interest, but on a shared system the CPU time is probably more important.

And how did you expand the data? Did you make several million different key values, or did you just repeat the ones from the original question? When the data set grows large, Richard's solution will need to hold all the defined key values in memory - may still not be a problem on a PC with a couple of GB RAM (provided that the key variables are not too much longer than in the example), but again on a shared system...

Anyway, I think your suggested solution can be simplified a bit, probably enough to save close to 30% time: The input data does have a sort order, so it is not necessary to run a data step just to save the original record number:

Proc sort data=have; by day code id_a id_b; run;

data want; set have; by day code id_a id_b; Flag_FO=first.id_b; Flag_LO=last.id_b; run;

proc sort; by day code time; run;

I think this is much simpler and therefore easier to understand and maintain.

Regards, Søren

On Sat, 9 May 2009 16:48:24 -0400, Arthur Tabachneck <art297@NETSCAPE.NET> wrote:

>Randy, > >If you have a lot of records, Richard's suggested code produces the same >results as mine, but runs about 30% faster on 9.1.3. > >Of course, on my machine at least, after expanding your file to 20+million >records, we're only talking about 12 seconds as compared with 8.5 seconds. > >Art >------- >On Sat, 9 May 2009 16:14:34 -0400, Randy <randistan69@HOTMAIL.COM> wrote: > >>Dear Art: >> Thanks for pointing out the error. It was indeed a mistake. I shall >run >>the code and let you guys know if it works. >> Randy


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