BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zdeb15
Calcite | Level 5

I am using SAS metadata to create a SAS macro called &SASAdmin....This macro will be used to store all the sas admin email address so I can send an email to all the SASAdmins. I want to dynamically set the value so I don't have to constantly manage the "TO" email address if an employee leaves or a new employee is hired. This code works if in the TO: line is hard coded such as

' 'email1@test.org "email2@test.org" ' 

 

but does not work if i put 

 

TO  "&SASAdmin"

 

 

Code is below:

 

 

options emailsys=smtp emailhost=smtp.test.org emailport=25;
FILENAME output EMAIL
SUBJECT= "SAS PROGRAM ERROR"
FROM= "test@test.org"
TO= "&SASAdmin"
importance='high'
CT= "text/html" /* Required for HTML output*/;
ODS HTML BODY=output STYLE=minimal;
title "<div align='Center' style ='font-size:12pt'> SAS PROGRAM ERROR TEST</div>";
footnote "<div style = 'font-size:10pt'> This E-mail is auto-generated from SAS on &sysday, &sysdate9.</div>";
footnote2 "<div style = 'font-size:10pt'> on the &sysscp system using Release &sysver </div>";

proc report data=enviromentspecs;
column programowner programpath lastruntime errortext;
define programowner / display;
define programprath / display;
define lastruntime / display;
define errortext / display;
label
programowner = 'Program Owner'
programpath = 'Program Path'
lastruntime = 'Program Last Run Time'
errortext = 'Program Error Text';
run;

 

 

 

errors:

 

ERROR 23-2: Invalid option name SASAdmin.
ERROR: Error in the FILENAME statement.
ERROR: No logical assign for filename OUTPUT.
ERROR: No body file. HTML output will not be created.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

When the macro variable that contains

"test1@test.org""test2@test.org""test3@test.org"

is resolved in this

TO= "&SASAdmin"

you get

TO= ""test1@test.org""test2@test.org""test3@test.org""

This can't work. A list of email recipients needs to be enclosed in parentheses (see the documentation), so you should use

TO=(&SASAdmin)

View solution in original post

6 REPLIES 6
zdeb15
Calcite | Level 5

Replicated code below: 

 

 

 

data temp;
infile DATALINES;
length emailaddr $20.;
input keyid$ emailaddr$ displayname$;
CARDS;
1 test1@test.org test1
2 test2@test.org test2
3 test3@test.org test3
;
run;
data temp1; set temp;

first = '"';
second = '"';

Email = catx('',first,emailAddr,second);
Email1 = compress(email);
TextList = 'NULL';
Team = 'SAS';
LastUpdateDt = datetime();
format LastUpdateDt datetime22.3;

run;
data temp2;

length emaillist $10000.;

do until (last.team);
set temp1;
by team notsorted;
emaillist=cats(emaillist,'',Email1);
end;
drop Email1 emailaddr first second email displayname keyid ;

run;
data _null_; set work.temp2;
call symput ('SASAdmin1',emaillist);
run;
%put sas admins are &SASAdmin1;

 

LOG:

%put sas admins are &SASAdmin1;
sas admins are "test1@test.org""test2@test.org""test3@test.org"

zdeb15
Calcite | Level 5

The code above is replicated (I changed the sasadmin to sasadmin1) but in the original code use SASADMIN and create SASADMIN. I did this to de-identify the actual email address of the recipients of the email but still be able to provide you with sample code that matches the original.  

Kurt_Bremser
Super User

When the macro variable that contains

"test1@test.org""test2@test.org""test3@test.org"

is resolved in this

TO= "&SASAdmin"

you get

TO= ""test1@test.org""test2@test.org""test3@test.org""

This can't work. A list of email recipients needs to be enclosed in parentheses (see the documentation), so you should use

TO=(&SASAdmin)
data_null__
Jade | Level 19
Show the value of &SASADMIN. Also include meaningful LOG output.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1683 views
  • 0 likes
  • 3 in conversation