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
Content-Type: text/plain; charset="iso-8859-1"
Doug,
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: bit.listserv.sas-l
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
>----------------------------------------------------------------------
|