简体   繁体   中英

sas passing quoted strings to a macro

so I have a dataset whose elements are strings of emails in quotes. A single data element might look like this: "john@cool.com" "jacob@cool.com" "jingleheimer@cool.com" "smith@cool.com"

I have the following macro command and data step:

%macro Emailer(RCP=);
/* body of the e-mail*/
data _null_;
    file tmp;
    put "Hello, World! <BR>";
run;

/*to-from*/
Filename tmp Email
Subject="Hello World Test"
To= (&RCP)
CT= "text/html";
%mend Emailer;

data _null_;
    set EmailLists;
    call execute('%Emailer(RCP='||ListOfEmails||')');
run;

But I keep getting "ERROR: Macro parameter contains syntax error."

Is it because my data elements have spaces or quotation marks or both?

Thanks in advance.

One way to test it is to pass the parameters directly, rather than with a data step. First I'll rearrange the order of the statements, as commenters pointed out.

%macro Emailer(RCP=);
  filename myEmail Email;
  data _null_;
    file myEmail Subject = "Hello World Test"
                 To = (&RCP)
                 CT = "text/html";
    put "Hello, World! <BR>";
  run;
  filename myEmail clear;
%mend Emailer;

And try making any of those work (can't make my 64-bit SAS work with my 32-bits Outlook so I can't test any of this):

%Emailer(RCP="john@cool.com" "jacob@cool.com" "jingleheimer@cool.com")
%Emailer(RCP="john@cool.com jacob@cool.com jingleheimer@cool.com")
%Emailer(RCP=john@cool.com jacob@cool.com jingleheimer@cool.com)
%Emailer(RCP=john@cool.com ; jacob@cool.com ; jingleheimer@cool.com)

After you figure out which form works, the rest should be easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM