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 (January 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 Jan 2004 09:54:52 -0800
Reply-To:     "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject:      Re: MERGE confusion and disbelief
Comments: To: "Cacialli, Doug" <Doug_Cacialli@URMC.ROCHESTER.EDU>

Doug -

As long as they each have the by variables in sort order you can merge as many as you want. Note they will overwrite each other where the keys are the same, so if B0 and W1 have the same by variables on an observation but W2 and the others don't, B0 will be read, W1 will be read over it, and it will be output. You should probably read up on merges: BY-Group Processing in the DATA Step - http://v8doc.sas.com/sashtml/lrcon/z1283274.htm (User:SAS Pwd:onlinedoc)

You may not know this, but you can also "set" data sets together with a "by" statement to retain their sorted order, rather than simply concatenating them and then performing an extra sort.

And be careful to always include your "by" statement, as SAS will perform a one-to-one merge without warning. I turn on my "options MERGENOBY=warn;".

hth

Paul Choate DDS Data Extraction (916) 654-2160

-----Original Message----- From: Cacialli, Doug [mailto:Doug_Cacialli@URMC.ROCHESTER.EDU] Sent: Tuesday, January 20, 2004 9:39 AM To: SAS-L@LISTSERV.UGA.EDU Subject: MERGE confusion and disbelief

Y'all,

I'm rewriting some non-functioning (or malfunctioning?) code written by a researcher in my department. In the midst of doing this, I came across:

DATA NANA; MERGE B0 W1 W2 W3 W4 W5 W5 W6 W7; BY PATID DRUG; RUN;

SAS doesn't mouth-off ... it seems to be okay with this. I would've never attempted this, as I am under the impression that you can't merge more than two sets in one data step. This has been my impression since I started using SAS 2.5 years ago.

Have I been living a lie? Can you merge multiple (i.e., more than two) data sets in one statement like this, or is the result the merge of the first two? And if that's the case, why isn't SAS all pissed off that I'm submitting crappy code?! Thanks for the help.

Doug out.

------------------------------------------- Doug Cacialli - Data Manager / Data Analyst Depression Research Laboratory University of Rochester Medical Center 300 Crittenden Boulevard - Box PSYCH Rochester, New York 14642 Phone: (585)273-3309 Fax: (585)506-0287 -------------------------------------------


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