0
votes

so I have a dataset whose elements are strings of emails in quotes. A single data element might look like this: "[email protected]" "[email protected]" "[email protected]" "[email protected]"

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.

1
Your macro looks upside down. You are writing to the file TMP before you define it with the FILENAME statement. - Tom
Can I invoke the data step immediately after the FILENAME statement? - Jesse_m_m
You can reference the fileref defined by the FILENAME statement any time after it is defined. You should post clearer examples of what the input dataset EMAILLISTS has in it. Does it have multiple records or just a single record? - Tom
Agree with @Tom - can you also paste the log where the error pops up? - Altons

1 Answers

1
votes

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="[email protected]" "[email protected]" "[email protected]")
%Emailer(RCP="[email protected] [email protected] [email protected]")
%Emailer([email protected] [email protected] [email protected])
%Emailer([email protected] ; [email protected] ; [email protected])

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