|
Dan,
Try using a SQL statement with an into : <macro variable> to get your
datasets from your library.
Then if your goal is to merge them all together in one huge file with
demofile do something like the following;
%macro merge_demo;
Data bigfile;
merge demofile (in=a)
%do I = 1 to &stop;
%let dsn = %scan(<your macro var>, &I);
&dsn (in=b rename = (newvar = &dsn._newvar) keep=(id trial
&dsn._newvar));
%end;
by id trial;
You will noticed I renamed your newvar variable. I assumed that all
datasets to be merged had the same var and you have to have some way to
distinguish them from one another or they will be overwritten by the
next data set.
HTH
Toby Dunn
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Dan
Litsky
Sent: Tuesday, June 29, 2004 8:35 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Loop to merge multiple datasets to one dataset
I have 250 datasets in one directory all starting with the letters "ds"
and numbered semi-sequentially. So there is a ds1 ds2 ds5 ds8, etc.
There are "holes" in the numbers.
I want to merge all of these datasets to one dataset containing
demographic information. The multiple datasets all contain one field
that I need on the new large dataset.
My merge might look like this:
Data bigfile;
merge demofile (in=a)
ds1 (in=b keep=(id trial newvar));
by id trial;
I'd like to read through the entire directory and merge in a loop if I
could. Is there a way to do this? I've check through the archives but
must be using the wrong set of search words because I can't find
anything that applies.
Thanks,
Dan
---------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
|