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 (March 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Mar 2002 12:25:22 -0500
Reply-To:     Robert Virgile <virgile@ATTBI.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Robert Virgile <virgile@ATTBI.COM>
Subject:      Re: Using MERGE with identical data set names
Comments: To: "Cacialli, Doug" <Doug_Cacialli@URMC.ROCHESTER.EDU>
Content-Type: text/plain; charset="iso-8859-1"


You can, but don't do it to solve this problem. The way you have structured your macro, you'd execute multiple data steps. Try this instead:

%macro sleep_merge;

data sleeptime; merge %do i = 1 to &maxvar; sleeptime&i %end; ; by id; run;

%mend sleep_merge;

If &maxvar is too large, you may have to run this in batches. Your hardware may have a limit as to how many files can be open at once. Just for the record, UPDATE is allowed to add variables (as well as new values for your by variables).

Good luck.

Bob V.

-----Original Message----- From: Cacialli, Doug <Doug_Cacialli@URMC.ROCHESTER.EDU> Newsgroups: To: SAS-L@LISTSERV.UGA.EDU <SAS-L@LISTSERV.UGA.EDU> Date: Wednesday, March 20, 2002 12:14 PM Subject: Using MERGE with identical data set names

>Y'all, > >I'm hoping this is a question that won't be too awfully hard to answer. I'm >trying to merge multiple data sets using a macro. The macro is necessary >because I won't know how many data sets I'm merging going in. I have a >macro variable (&maxvar) which is the number of data sets, and my macro >looks a little something like this: > >%macro sleep_merge; >%do i = 1 to &maxvar; >data sleeptime1; > merge sleeptime1 sleeptime&i; > by id; >run; >%end; >%mend sleep_merge; > >My question is whether I can use the same data set name for the new data set >and data set 1? I can't use UPDATE to add variables, can I? I'm open to >any ideas. Thanks in advance! > >Regards, > >Doug >---------------------------------------------------------------------- >Doug Cacialli - Information Analyst / Laboratory Coordinator >Sleep Research Laboratory >Department of Psychiatry >URMC - Strong Memorial Hospital >300 Crittenden Blvd. >Rochester, New York 14642 >Phone - (585) 275-2900 Fax - (585) 273-3682 >----------------------------------------------------------------------

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