- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How did you create the macro variable &sasadmin? Please show that piece of code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You create sasadmin1, but try to use sysadmin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content