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

Hi ,

is it possible to create a batch in SAS that picks up a file from a  particular UNIX location and emails  it to myself for example?

 

I dont have certain dates when that file will be in UNIX

 

pls advise

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Use the Fexist or FileExist functions.

https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210912.htm

The example is pretty much what you want, except you want more stuff to happen in the IF/THEN sections. You may have to use different parts from different questions but the solutions are on here.

View solution in original post

8 REPLIES 8
Reeza
Super User
Yes, it's possible. You'll have to schedule the script to run and check if the file exists, if it exists then do A, otherwise stop. There are code samples on here if you search.
SASKiwi
PROC Star

Yes. Assuming that SAS is running on the Unix server and that it is configured to work with an email server.

 

Why do you want to use email? What happens if the file is too large to send as an email attachment? Most email systems have restrictions on this.

 

Also there are schedulers that can check for the existence of a file and then run a batch job. 

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

thanks guys,

I usually pick up the file from our server manually and load it to another server which is not owned by us but now the guys asked me  if i can  pick it up  and email it to them directly instead of loading it to their server.

Can you please point where on here i can get the samples  of those scripts or even the scheduler that check for existence?

 

thanks,

Reeza
Super User
Does it have to be a SAS script, there are a lot more Unix scripts out there I would imagine, and it's probably more efficient.
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

i dont know how to  write scripts in UNIX

SASKiwi
PROC Star

Here is a link that has some code example for sending emails with attachments:

 

http://support.sas.com/documentation/cdl/en/hostunx/67929/HTML/default/viewer.htm#p1hl3t66coao7bn18v...

 

You should talk to your SAS administrator to confirm your site's email settings if any.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

thanks SaSKiwi,

i did try one of the codes  from the link  you sent me and looks like my SAS is not set up to talk to SMTP yet.

 

Can you also point to some codes that check to see if a  file exists in  a particular server  and then picks it up before sending it via email?

Reeza
Super User
Use the Fexist or FileExist functions.

https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210912.htm

The example is pretty much what you want, except you want more stuff to happen in the IF/THEN sections. You may have to use different parts from different questions but the solutions are on here.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 8 replies
  • 1529 views
  • 3 likes
  • 3 in conversation