DATA Step, Macro, Functions and more

Emailing With SAS

Reply
Frequent Contributor
Posts: 97

Emailing With SAS

I am trying to setup email using sas, with no luck. Here is the code I am trying to run:

FILENAME MAIL EMAIL "myemail";
DATA _NULL_;
FILE MAIL;
RUN;


Here is the error I get:

ERROR: Undetermined I/O failure.


I am working in SAS Enterprise 4.1 (SAS 9.1) on a Windows XP machine. Don't know if it matters, but I have MS Office 2007.

I have set the SMTP server and email address in the Options menu. Is there something else I have to do?

Any help is greatly appreciated.

Thanks,
Chris Message was edited by: cjohnson
Christopher Johnson
www.codeitmagazine.com
Super Contributor
Super Contributor
Posts: 3,174

Re: Emailing With SAS

Is it possible that your DATA step failed to write any records to the output destination, resulting in an error condition? Suggest adding a PUT statement with some text output.

Scott Barry
SBBWorks, Inc.
Frequent Contributor
Posts: 97

Re: Emailing With SAS

Thanks for responding so quickly. I added a Put statement, but still get the same error.

FILENAME MAIL EMAIL "christopher.johnson@brickstreet.com";
DATA _NULL_;
FILE MAIL;
PUT "THIS IS A SAS EMAIL TEST";
RUN;
Christopher Johnson
www.codeitmagazine.com
Contributor
Posts: 29

Re: Emailing With SAS

Try putting
run;
between your filename statement and the data _null
Frequent Contributor
Posts: 97

Re: Emailing With SAS

Tried, but I still get the same error.

FILENAME MAIL EMAIL "christopher.johnson@brickstreet.com";
RUN;
DATA _NULL_;
FILE MAIL;
PUT "THIS IS A SAS EMAIL TEST";
RUN;
Christopher Johnson
www.codeitmagazine.com
Super Contributor
Super Contributor
Posts: 3,174

Re: Emailing With SAS

Suggest adding a FILENAME with CLEAR for your used. It's unclear at what point you actually get the error - you may want to open a SAS Support track for this problem.

Also, you may need to verify whether you have sufficient authority on your local machine -- possibly there is some information in your system logs to help debug.

Lastly, you will want to use PROC OPTIONS and verify the SAS CONFIG options for EMAILSYS=, EMAILHOST= and EMAILPORT= on your machine.

Scott Barry
SBBWorks, Inc.
Frequent Contributor
Posts: 97

Re: Emailing With SAS

Thanks! I set the SMTP server in the SAS Options Menu, but knew there would be more I needed to do. Here are the current settings:

EMAILAUTHPROTOCOL=NONE
Identifies the SMTP e-mail authentication protocol
EMAILHOST=LOCALHOST
SMTP server host for email access method
EMAILID= From E-mail address, log in id, or profile for use with underlying e-mail system
EMAILPORT=25 Port number for SMTP server for email access method
EMAILPW= Used by the E-mail Access Method and Send menu item to set the email session login password for the underlying
e-mail system


Did not see an EMAILSYS option. I checked with IT, and the port is correct. Is there anything else I need to set?

Thanks very much,
Chris Message was edited by: cjohnson
Christopher Johnson
www.codeitmagazine.com
SAS Super FREQ
Posts: 8,862

Re: Emailing With SAS

Hi:

For more information about the "rules" of using the FILENAME EMAIL engine, refer to the Help topic: Sending Electronic Mail from Within the SAS System (EMAIL) or the SAS documentation for your operating system. Note that you may need to change SAS system options related to emailing in order for these techniques to work. Also, if you go to Tech Support and search for the terms 'Email' and 'ODS', there are a lot of hits which describe various issues or troubleshooting tips:

http://support.sas.com/techsup/unotes/SN/013/013786.html
http://support.sas.com/techsup/unotes/SN/009/009243.html
http://support.sas.com/techsup/unotes/SN/009/009459.html
http://support.sas.com/techsup/unotes/SN/005/005334.html
http://support.sas.com/techsup/unotes/SN/005/005335.html
http://support.sas.com/techsup/unotes/SN/016/016339.html
http://support.sas.com/techsup/unotes/SN/013/013503.html
http://support.sas.com/techsup/unotes/SN/018/018363.html

Here are some other useful links:
http://support.sas.com/ctx/samples/index.jsp?sid=464
http://www2.sas.com/proceedings/sugi29/170-29.pdf
http://www2.sas.com/proceedings/sugi29/178-29.pdf

For more help with email issues, your best bet is to contact Tech Support -- since different operating systems require different settings for email to work.

cynthia
Trusted Advisor
Posts: 2,115

Re: Emailing With SAS

Since you are using EGuide, you could try sending a file using the EGuide tool (right-click on an object, select send, select send as a step in the project). That will use EGuide best-practices to connect to the SMTP gateway. That will help isolate the problem.

Also, I suspect that the SMTP gateway settings in EGuide do not get passed to the SAS server for your code task. You are likely to have to set up the connectivity again within SAS 9.1.

Doc Muhlbaier
Duke
Occasional Contributor
Posts: 16

Re: Emailing With SAS

Try to add the «to=» «type=» and «subject» conditions to the filename declaration.
For example your previous code would change into:

FILENAME MAIL EMAIL to=("christopher.johnson@brickstreet.com")
subject="Test"
type='text';
Ask a Question
Discussion stats
  • 9 replies
  • 440 views
  • 0 likes
  • 6 in conversation