LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (May 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 16 May 2002 16:40:09 -0400
Reply-To:   "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Subject:   Re: data manipulation
Comments:   To: Ian Whitlock <WHITLOI1@WESTAT.com>
Content-Type:   text/plain; charset=iso-8859-1

> Paul, > > I know it is too slow for you, but for others it might make sense to > implement the stack with the more standard and simpler code: > > length stack $ 3 ; > stack = substr(stack,2) || type ;

Ian,

I have thought of it for a second, then decided to use PEEKC() for two reasons:

1) to demonstrate another time how it can be useful and how to use it 2) to induce you to chime in

This way, I thought I would have more territory covered without having to show both techniques, and it looks like I was right.

> Now how many bottles of beer are left or is the stack empty?

If you take I-95 South right away and stay on it and on gas until you find yourself in Jax, you will make it on time to catch a few left. Like I said earlier, this beer is not conducive to be drunk by cases :-).

Kind regards, ================== Paul M. Dorfman Jacksonville, FL ==================

> IanWhitlock@westat.com > > -----Original Message----- > From: Dorfman, Paul [mailto:Paul.Dorfman@BCBSFL.COM] > Sent: Thursday, May 16, 2002 3:21 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: data manipulation > > > Gregg, > > Right, but why bother resorting the stuff (potentially at a > high processing > cost) if the same can be done by keeping a simple 3-item > stack? Something > along the lines > > data cid (keep = id) ; > array t (3) $1. ; > do c = 1 by 1 until (last.id) ; > set a ; > by id ; > t(3) = t(2) ; > t(2) = t(1) ; > t(1) = type ; > end ; > if index (peekc(addr(t1), 3), 'C') ; > run ; > > This obviously preserves the original order. Or else one can > fancier and > read the file backwards and use the traditional > do-it-yourself control break > (i.e. without first./last. that cannot be used below for > obvious reasons): > > data cid (keep = id) ; > do p = n by 0 until (p = 1) ; > do c = 1 by 1 until (nextid < id | p = 1) ; > p +- 1 ; > id = nextid ; > set a (rename=(id=nextid)) point = p nobs = n ; > if c <= 3 and type = 'C' then c = - n - 3 ; > end ; > if c < 0 then output ; > end ; > stop ; > run ; > > The values of ID obtained in one of these fashions can be > either merged with > the original file if needed. For this, the second method > seemingly requires > resorting, but you ought to know better than anyone else that > is not quite > true :-). > > Kind regards, > ================== > Paul M. Dorfman > Jacksonville, FL > ================== > > > > -----Original Message----- > > From: Gregg Snell [mailto:gsnell@DATASAVANTCONSULTING.COM] > > Sent: Thursday, May 16, 2002 11:15 AM > > To: SAS-L@LISTSERV.UGA.EDU > > Subject: Re: data manipulation > > > > > > Santosh, > > > > Just a few days ago a sort-of-similar question was asked and > > the very clever > > solution suggested was to simply re-sort the data in reverse > > order (i.e. > > descending id) and then check for 'C' in any of the FIRST > > three occurances. > > > > Regards, > > > > Gregg P. Snell > > Data Savant Consulting > > (913) 638-4640 > > (208) 977-1943 fax > > http://www.datasavantconsulting.com > > > > > > "Santosh Verma" <santoshkverma@HOTMAIL.COM> wrote in message > > news:200205161452.g4GEqIh22373@listserv.cc.uga.edu... > > > Hi, > > > > > > Data looks like following. > > > > > > id service_date type_of_service > > > 1 1/1/11 A > > > 1 2/3/11 B > > > 1 3/3/11 D > > > 1 4/4/11 A > > > 1 5/6/11 B > > > 1 6/7/11 C > > > 2 > > > 2 > > > 2 > > > ...... > > > 3 > > > 3 > > > 3 > > > ..... > > > > > > Data is obviously sorted by id and service date. I want to > > check if any of > > > the last three services for each id is of the service type > > 'C'. We do not > > > know no of obs for each id, which is different for every id. > > > > > > Thanks > > > Santosh > > > > > > > > > > > Blue Cross Blue Shield of Florida, Inc., and its subsidiary and > affiliate companies are not responsible for errors or > omissions in this > e-mail message. Any personal comments made in this e-mail do > not reflect the > views of Blue Cross Blue Shield of Florida, Inc. > >

Blue Cross Blue Shield of Florida, Inc., and its subsidiary and affiliate companies are not responsible for errors or omissions in this e-mail message. Any personal comments made in this e-mail do not reflect the views of Blue Cross Blue Shield of Florida, Inc.


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