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 (October 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 12 Oct 2010 12:40:23 -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: Seeking merge value???
Comments: To: Sarah Cox <saslearner2006@GMAIL.COM>

How's this?

data xx; input Grade Name $; cards; 1 Joe 2 Rose 2 Tiff 3 Tim 4 Tom 4 Pat 2 Jay 3 Kim 3 Bob ;

proc sql; create table yy as select a.name as manager,b.* from xx a, xx b where a.grade=b.grade-1 order by b.grade,b.name ;

data yy; set yy; by grade name; if first.name; run;

proc sort data=xx; by grade name; run;

proc sort data=yy; by grade name; run;

data final; merge xx yy; by grade name; run;

proc print; run;

Obs Grade Name manager

1 1 Joe 2 2 Jay Joe 3 2 Rose Joe 4 2 Tiff Joe 5 3 Bob Tiff 6 3 Kim Rose 7 3 Tim Tiff 8 4 Pat Tim 9 4 Tom Kim

HTH

Ya

On Tue, 12 Oct 2010 12:12:28 -0400, Sarah Cox <saslearner2006@GMAIL.COM> wrote:

>Hi, I am having a very challenging data. The data have all employee's name >and grade level, and need to assign the manager to the employee based on the >grade. One grade may have several people and the lower grade people should >report to the direct up grade people. (The )So here is the data structure: > >Gread Name Manage >1 Joe >2 Rose >2 Tiff >3 Tim >4 Tom >4 Pat >2 Jay >3 Kim >3 Bob > >So here is the sopposed manager for each person. > > Gread Name Manage >1 Joe >2 Rose Joe >2 Tiff Joe >3 Tim Tiff >4 Tom Tim >4 Pat Tim >2 Jay Joe >3 Kim Jay >3 Bob Jay > >What's the best way to matach and get the right manager? I was thinking some >count, lag funciton, but just can't think through. Your valuable advice >would be really appreciated! > >Sarah


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