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

Hello everyone!

I want to send mail to a particular user by attaching excel file with current date from a particular location . But I am getting error while running the below program.

Can anyone help me as I am not experienced.

Location of Excel file: - 'C:\Program Files\Cisco\Meddra term updated_03JAN2013.XLS'

FILENAME Mailbox EMAIL 'manager@cisco.com'

Subject='Test Mail message'

ATTACH= 'C:\Program Files\Cisco\Meddra term updated_||put("&sysdate9"d ,date9.)||".xls"'

;

DATA _NULL_;

FILE Mailbox;

PUT "Hello";

PUT "Test mail ";

RUN;

N:B: The excel output file will be updated with current date everyday in the above location.

1 ACCEPTED SOLUTION

Accepted Solutions
overmar
Obsidian | Level 7

Put " rather than ' in that line of code, macros don't like running in single quotes

so subject should be

Subject="Test Mail message_&print_date"

View solution in original post

5 REPLIES 5
overmar
Obsidian | Level 7

First question: You have set up your email setting through your .cfg file correct? My guess is yes bc it sounds like this is just a question about how to get it to go from the correct date. If not you will first need to set that up so you can email from SAS.

Second: run this line of code before the filename statement

%let print_date = %sysfunc(today(), date9.);

Third: You will need a from=("you@you.org") to=("manager@cisco.org)

Fourth: You then can run it write the attach statement as such:

ATTACH= "C:\Program Files\Cisco\Meddra term updated_&print_date..xls"

Since you previously had stated what the print_date macro should output you then can just insert it into the attach statement.

In the end the code should look like this:

%let print_date = %sysfunc(today(), date9.);

FILENAME Mailbox EMAIL from=("you@you.org")

to=("manager@cisco.org)

ATTACH= "C:\Program Files\Cisco\Meddra term updated_&print_date..xls"

;

DATA _NULL_;

FILE Mailbox;

PUT "Hello";

PUT "Test mail ";

RUN;

Abraham
Obsidian | Level 7

Thank You very much for your great help.

One question

How to add the current date in the subject of text. Its not working. Can you please help.

Subject='Test Mail message__&print_date'

overmar
Obsidian | Level 7

Put " rather than ' in that line of code, macros don't like running in single quotes

so subject should be

Subject="Test Mail message_&print_date"

Abraham
Obsidian | Level 7

Its working fine now. I forgot to ask one more question .

If I want to attach multiple file , then can I write like this.

ATTACH= ("C:\Program Files\Cisco\Meddra term updated_&print_date..xls"

                 "C:\Program Files\Cisco\Meddra term updated_&print_date..pdf"

                  "C:\Program Files\Cisco\Meddra term updated_&print_date..doc"

               )

overmar
Obsidian | Level 7

Correct and make sure to put the parentheses outside of the file names, they are not required if you are only sending one file, but are if you are sending multiple ones.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 5 replies
  • 989 views
  • 3 likes
  • 2 in conversation