=========================================================================
Date: Fri, 19 Jul 2002 10:24:18 -0400
Reply-To: Kristi Mahadocon <kmahadocon@PDL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kristi Mahadocon <kmahadocon@PDL.COM>
Subject: set data within a macro?
I am creating a by patient report and need to concatenate several data
sets. I have created a data set in my program that puts the data sets into
an array and gives them the generic names dat1, dat2, dat3...dat32. The
number of datasets for a given library is stored in a macro variable &num.
So, I have a dataset with one observation that looks like this:
obs dat1 dat2 ....... dat32
1 s030p200 s030p206 s030p499
and &num=32
How can I automate a set statement that will concatenate all 32 data sets?
This is what I tried, but only the first observation from each data set is
output.
**this section renames the dat1...dat32 datasets to newname1...newname32
and creates them as global macro variables;
data _null_;
%macro setup;
set datasets;
%do i = 1 %to #
%global newname&i;
call symput("newname&i",dat&i);
%end;
%mend setup;
%setup;
**This secion is where I am trying to 'set' the data sets one after the
other, but am having trouble. &name is a global macro variable for my
library ref;
%macro setall;
data test(keep=ptid visit plate);
%do x = 1 %to #
set &&name..&&newname&x;
output;
%end;
%mend setall;
%setall;
I want my output data set to look like
Obs1 from dat1
Obs2 from dat1
.....
Obsn from dat1
obs1 from dat2
obs2 from dat2
....
obsn from dat2
etc.
Any suggestions on how to accomplish this would be greatly appreciated.
Thank you,
Kristi Mahadocon
Bioanalyst