| Date: | Fri, 19 Dec 2003 11:13:31 -0500 |
| Reply-To: | "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV> |
| Subject: | Re: Passing a ds of filenames into macro |
|
| Content-Type: | text/plain; charset="us-ascii" |
keyword: list processing
> From: Craig Gale [mailto:cgale@CC.USU.EDU]
> This feels like a straight-forward problem, but I can't find
> the answer and would appreciate any input!
>
> I have a dataset (FILEDS) that contains two fields, FILE1 and
> TABLE1. FILE1 is a character string that contains a filename,
> including path. (filename is actually an Access database)
> TABLE1 is a character string that contains an Access table
> name. FILEDS contains about 500-records, pertaining to 500
> unique FILE1/TABLE1 combinations. I would like to pass the
> values of FILE1 and TABLE1 into a macro.
>
> For example, I have a macro called %compare(dsdb,dst) that
> I'm trying to call in the following way:
>
> data _null_;
> set FILEDS;
> %compare(FILE1,TABLE1);
> run;
>
> Of course, the parameters dsdb and dst are assigned the
> literal values FILE1 and TABLE1. How can I assign dsdb and
> dst the actual values of FILE1 and TABLE1??
note: macro array is a good solution, too,
as others has already posted
you may also use either call execute:
data _null_;
set Fileds;
call execute( '%nrstr(%compare(dsdb='
!! trim(FILE1)
!! ',dst='
!! trim(TABLE1)
!! '))'
);
run;
or SQL:
PROC SQL;select '%compare(dsdb='
!! trim(FILE1)
!! ',dst='
!! trim(TABLE1)
!! ')'
into :List
separated by ' '
from FILEDS
;quit;
&List.
Ron Fehd the SQL into:macro maven CDC Atlanta GA USA RJF2@cdc.gov
Repetition obfuscates!
Repetition reduction enhances elegance!
Repetition reduction furthers finesse!
|