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 (April 2012, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 6 Apr 2012 17:33:18 +0000
Reply-To:   "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Subject:   Re: Determining which element of an array has the desired value
In-Reply-To:   <9F0A90FE1B47E74DB4DF72EC940E33AC18E1F3D1@EMBX-CHAM4.cdc.gov>
Content-Type:   text/plain; charset="us-ascii"

This is more obvious and you don't have to deal with the index being incremented past the loop exit

do I = 1 to dim(date-old); do J = 1 to dim(date-old);*until matched dates; if date-index(J) = date-old(I) then do; date-new{J) = date-old(I); school-new(J) = school-old(I); leave; end; end; end;

> Ron Fehd here(we(are)) maven

> -----Original Message----- > From: Fehd, Ronald J. (CDC/OCOO/ITSO) > Sent: Friday, April 06, 2012 12:35 PM > To: 'SAS-L@LISTSERV.UGA.EDU' > Subject: RE: Determining which element of an array has the desired value > > > From: Andrew Karp/Sierra Information Services > > Sent: Friday, April 06, 2012 9:26 AM > > To: SAS-L@LISTSERV.UGA.EDU; Daniel Nordlund > > Subject: Re: Determining which element of an array has the desired > > value > > > > Hi all... > > > > I really appreciate the time and effort several of you have put in to > > answering my query, but I guess I was not clear on what I really need/want. > > > > The issue is that the degrees are not listed in the date order they > > were granted in the source field (a text field in a university data > > base). In my example I posted yesterday, the earliest degree earned > > is the second of the three degree dates listed in the field. > > > > What I need is a way to assign to Degree_1 the *earliest* (in time) > > degree earned that is listed in the source field and to Degree_2 the > > "next" (in > > time) degree the student earned and to degree_3 the "last" (or most > > recent, in time) degree earned and to then assign to school_1 the name > > of the school which granted the first degree (in time) they earned. > > > > Is there a solution to this problem using, perhaps, some aspect of the > > ARRAY facility I can't conjure up at the moment? > > > > Thanks again, > > Andrew > > Hi Andrew > > I see that most folks want to vertical the data, transpose and then flatten > > When I wrote up SAS implementations of Knuth's sorting algorithms > > http://www.sascommunity.org/wiki/Category:Knuth > > one of the things I learned was that one could use an array reference as the > index of another array reference. > > i.e., in the distribution counting algorithm: > > Count{K{J}} + 1; > > it seems to me a solution will need these arrays date-old school-old > > date-index _temporary_ > > date-new > school-new > > the interesting part of this in-row processing is that the dates are not > integers, thus not candidates for an array index. > > the problem is how to associate a date with an index value. > > the solution is something like: > do I = 1 to dim(date-old); > date-new(I) = (date-index(date-old(I))); > school-new(I) = ...; > end; > > I think sorting the date-old into the data-index array is straight-forward then > you need to search the date-index for a match > > do I = 1 to dim(date-old); > do J = 1 to dim(date-old); > if date-index(J) = date-old(I) then leave; > end; > date-new{J) = date-old(I); > school-new(J) = school-old(I);; > end; > > Here is a reference on exiting loops and the index values to expect: > > http://www.sascommunity.org/wiki/Do_which_loop_until_or_while > > Ron Fehd we(are(here)) maven


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