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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 16 Apr 2008 20:02:05 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: How to use lookup function to merge data from a standard list
              file
Comments: To: jn mao <jn_mao@yahoo.com>
In-Reply-To:  <663936.21515.qm@web32702.mail.mud.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

I geez Ill give you the easy version (however id normally do this with a Hash).

Proc SQL ; Create Table Need As Select Tbl2.* , Tbl1.Category From Table2 As Tbl2 Left Join Table1 As Tbl1 On Tbl1.Var1 = Tbl2.Var2 ; Quit ;

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Wed, 16 Apr 2008 12:55:10 -0700 > From: jn_mao@YAHOO.COM > Subject: Re: How to use lookup function to merge data from a standard list file > To: SAS-L@LISTSERV.UGA.EDU > > No, the data1 has 100 category and 200 data, var1 has data with fall in 100 category (category). Data2 has 400 subjects. I need to find each subject fall in which category according to var2. > > > > Mary wrote: > I think that what you mean is that you have two data sets with an equal number of rows that you want to merge together, and they match row for row, but you don't have an ID field on data 1. > > Try this: > > data data1; > obsnum + 1; > run; > > data data2; > obsnum + 1; > run; > > data mergeset; > merge data1 data2; > by obsnum; > run; > > -Mary > ----- Original Message ----- > From: jn mao > To: SAS-L@LISTSERV.UGA.EDU > Sent: Wednesday, April 16, 2008 2:27 PM > Subject: How to use lookup function to merge data from a standard list file > > > Hello SAS-Ls, > > I have a standard list file with 100 category. And I have another data2 file with all subjects. In data2, var2 need be matched to the list file, and find the category it belongs. > > data1 (list file): > var1 category > aa 1 > bb 1 > cc 2 > > data2: > Id var2 > 1 aa > 2 cc > 3 bb > > I need add category to data2. When I tried use merge, I lost all ID data which means all ID data become missing. > Could someone help me to add the category in data2? Thanks much. > > Jane > > > --------------------------------- > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. > > > --------------------------------- > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.

_________________________________________________________________ Get in touch in an instant. Get Windows Live Messenger now. http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_getintouch_042008


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