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 (July 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 7 Jul 2006 13:22:59 -0400
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: finding minimum value in most efficient manner
Comments: To: Jennifer Sabatier <plessthanpointohfive@GMAIL.COM>

Here is one using Howard's interleave trick:

data hx; input id jobtitle $ months; datalines; 1 Floater 3 1 Operator 1 1 Crew 8 1 Manager 30 2 Operator 5 2 Crew 2 3 Helper 1 4 Helper 10 4 Operator 56 4 Supervisor 22 4 Manager 10 ;

data hx; set hx (in=a_) hx (in=b_); by id; retain mina posa; if first.id and a_ then do; na_=0; nb_=0; mina=9999; end; if a_ then do; na_+1; nb_=.; if months < mina then do; mina=months; posa=na_; end; end; if b_ then do; nb_+1; na_=.; if nb_= posa then minflag=1; if nb_= posa-1 then preflag=1; output; end; drop mina posa na_ nb_; run;

proc print; run;

id jobtitle months minflag preflag

1 Floater 3 . 1 1 Operator 1 1 . 1 Crew 8 . . 1 Manager 30 . . 2 Operator 5 . 1 2 Crew 2 1 . 3 Helper 1 1 . 4 Helper 10 1 . 4 Operator 56 . . 4 Supervis 22 . . 4 Manager 10 . .

HTH

Ya

On Fri, 7 Jul 2006 12:44:01 -0400, Jen Sabatier <plessthanpointohfive@GMAIL.COM> wrote:

>Hello, all, > >I have a dataset of individual's work histories. So, there is are columns >for id, jobtitle, months. > >data hx; >input id jobtitle $ months; >datalines; >1 Floater 3 >1 Operator 1 >1 Crew 8 >1 Manager 30 >2 Operator 5 >2 Crew 2 >3 Helper 1 >4 Helper 10 >4 Operator 56 >4 Supervisor 22 >4 Manager 10 >. >. >. >; > > >So, we have unequal lengths to the actual work history. Some people held >several jobs, some just a few, and some only one. > >What I need to do is locate the shortest job held for each person for people >who held more than one job, flag it and the jobs before and/or after it. I >will need to examine the previous and/or prior job along with the shortest >job. If a person held only one job then I need to flag them seperately. > >I've tried to do this with an array but I can't make it work. I know it >must be simple. > >Hope someone can help!


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