- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a SAS extract that I would like to send as an excel file.
I want to send this to outlook.
My trail:
I exported the file to my local c: drive and then write the below code so SAS picks the file and attaches it as an excel and sends it.
I am getting the error :
ERROR: Error opening attachment file C:/Name of folder/Name of excelfile.xlsx.
ERROR: Physical file does not exist, /sas94apps/prod94config/Lev1/user/C:/Folder name/Excel name.xlsx.
Is there a way I can send this?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please provide the code how your attaching the file to email.
Here is a sample code:
filename outbox email
from='abc@abc.com'
to='abc@abc.com'
type='text/html'
subject='Test Mail'
attach=("/user/test.xlsx" content_type="excel");
ods html body=outbox rs=none style=Htmlblue;
proc odstext;
p 'Hello,';
p ' Please find the attachment';
p 'Thank You';
title;
run;
ods html close;
Also, it looks like your SAS is on Unix/Linux and your trying to attach a file that is in your local machine. SAS doesn't have communication for your local drive, so you may need to move the file to Unix or to a location mount between both.
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please provide the code how your attaching the file to email.
Here is a sample code:
filename outbox email
from='abc@abc.com'
to='abc@abc.com'
type='text/html'
subject='Test Mail'
attach=("/user/test.xlsx" content_type="excel");
ods html body=outbox rs=none style=Htmlblue;
proc odstext;
p 'Hello,';
p ' Please find the attachment';
p 'Thank You';
title;
run;
ods html close;
Also, it looks like your SAS is on Unix/Linux and your trying to attach a file that is in your local machine. SAS doesn't have communication for your local drive, so you may need to move the file to Unix or to a location mount between both.
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Below is the code I am using and getting the erros mentioned in my question
filename outmail email to=("new_Sas_user@xx.ca")
cc=("new_Sas_user@xx.ca")
replyto=("new_Sas_user@xx.ca")
subject=("Data")
attach=("C:/Folder Name/File_Name.xlsx" content_type="application/xlsx");
run;
DATA _NULL_;
FILE outmail;
PUT "Hello";
PUT "Plesae find Report as an attachment";
PUT "Thank you";
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please check your path, give a valid path name what SAS can read from. Is your SAS running on Unix/Linux or Windows local. Windows has '\' and linux/unix has '/', your are mixing them.
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am running SAS on a windows laptop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What SAS Application your connected to? SAS Studio, SAS Enterprise Guide, PC SAS ?
Your using Windows laptop doesn't mean that your running SAS that was installed in your laptop. Your log shows ---> /sas94apps/prod94config/Lev1/user which I suspect that your SAS is installed on a server (unix/Linux) and your connecting to it through the application your using (I guess it might be SAS Enterprise Guide ).
Are you using SAS EG (Enterprise Guide) ?
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
yes, I am using SAS Enterprise Guide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc setinit;
run;
Run this and check the log for operating system or check the location C:\Program Files\SASHome\SASFoundation\9.4 for SAS to see if SAS is installed in your local machine. If you have SAS installed in local machine then check whether your running on server "LOCAL" in SAS EG. Some people have multiple servers listed (View>Servers List).
If you don't have SAS installed locally then you have to copy your file to server, check this link for copy files option in SAS EG. Once the files are moved to serve then you have to use the server path. (Under server>Files>several folders here). Find a location where you have access on server to save your work.
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS is installed on my local machine but I am not running on the LOCAL server
I am running on
Selected server: BIApp_User
My extracts are produced under the work library.
I want to send the excel version of the extract
If I specify /sas94apps/prod94config/Lev1/BIApp_USER/Work.my_extract_file_name.xlsx
I get the error: Physical file does not exist, /sas94apps/prod94config/Lev1/BIApp_USER/Work.my_extract_file_name.xlsx"
content_type="application\xlsx.
Any thoughts on how can I resolve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When it says physical file doesn't exists, you need to make sure the path your providing really exists.
Try this trick to find the physical path for the file:
In SAS EG, can you see your file (.xlsx) when you navigate through "Files"
If yes, drag and drop in the project flow and by default it will try to import. In the import wizard you can actually file the right physical path for that particular file. If by default import wizard doesn't open then go to file>import data
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I see files under my WORK library (but they are sas formatted).
I want to send the file as an excel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Then you have to create the excel files first in a location where you have access.
proc export
data=work.<your dataset name here>
dbms=xlsx
outfile="/user/mypath/export_test.xlsx"
replace;
run;
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Suryakiran!!
I am now able to send the file to my BIApp_User folder under servers.
Using the below code:
FILENAME Mailbox EMAIL 'myemail@xxxx.ca'
Subject='Test Mail message'
ATTACH="/users/mypath/my_filename.xlsx" ; /*I am using the same folder location I used to export the file*/
run;
/*subject line of the mail*/
DATA _NULL_;
FILE Mailbox;
PUT "Hello"; /*mail body*/
PUT "This is a message from the DATA step";
RUN;
I am receiving a message in my outlook mailbox
(Hello
This is a message from the DATA step.)
There is an excel attachment name my_filename but when I open it it says ""
"We found a problem with some content in 'myfilename.xlsx' . Do you want to try to recover as much as we can? If you trust the source of this workbook, click Yes "
How can I resolve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please check my initial reply that give an example code to send the excel file, you require content_type='excel'
attach=("/user/test.xlsx" content_type="excel")
Suryakiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a ton 🙂
Finallyyyyy able to do it !!!
Thanks again!!!!!!