Date: Tue, 6 May 1997 15:45:56 GMT
Reply-To: Jay Weedon <j_weedon@ESCAPE.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Jay Weedon <j_weedon@ESCAPE.COM>
Organization: None
Subject: Re: Passing a list of filenames to a macro variable
Content-Type: text/plain; charset=us-ascii
On Mon, 05 May 1997 15:42:07 -0400, Jason Yarrington <jasony@pop.psu.edu>
wrote:
>I would like to modify the following code to pass a file of file names
>to the macro that I have written
>
>I have a file that looks like this:
>
>exp09001.dbf
>exp09003.dbf
>exp09011.dbf
>exp12111.dbf
>.
>.
>.
>
>And I would like to read the file and pass each file name to the macro
>below, in place of the parameter.
>
>%let srcpath = /home/yada/yada/yada/report/;
>
>%macro dbfconv(thisfile) ;
>filename dbdum "&srcpath.&thisfile..dbf";
>proc dbf db3=dbdum out=&thisfile ;
>%mend dbfconv;
>
>%dbfconv(exp09001); run;
>%dbfconv(exp09003); run;
>
>data one;
> set
> exp09001 exp09003
> ;
>
>Any suggestions would be greatly appreciated.
Assuming that your file containing the filenames is called mydir/names.txt,
you could try something like this:
* Initialize macro var SET as null string (will eventually contain string
exp09001 exp09003 ...);
%let set=;
data _null_;
* Read file containing filenames;
infile "mydir/names.txt";
input fname $;
* Concatenate filename in current record to macro var SET;
call symput( "set", symget("set") || " " || fname );
* Set up macro DBFCONV to execute w/current filename AFTER current datastep;
call execute ( "%dbfconv(" || fname || ")" );
run;
* Following datastep will be executed AFTER repeated executions of macro;
data one;
set &set;
run;
Jay Weedon.