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 (December 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 31 Dec 2008 10:30:28 -0500
Reply-To:     Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:      Re: How to each group last record ?
In-Reply-To:  <200812311402.mBVBmfFF006266@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

>hi friends > > > >I have small doubt plz replay. > > > >How to get each group last record with out sort table . bcz my > >dataset have lacks of observation > >if i sort i will take to time. > > Following Howard's Hash solution, there is another way in case you work with V8.

Unlike Hash solution, you need to give the program the maximum of the variable you are grouping by. Using SASHELP.CLASS, the maximum of AGE cannot be greater than 99. It is passed to the program as a macro variable. The array holds the observation pointer, replacing the cell every time by the last pointer of the age.

%let max_age = 99; data need; do _n_ = 1 by 1 until(eof); set sashelp.class end = eof; array k[&max_age] _temporary_; k[age] = _n_; end; if eof then do _n_ = 1 to &max_age; if k[_n_] > 0 then do; p = k[_n_]; set sashelp.class point = p; output; end; end; stop; run;

Muthia Kachirayan


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