BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

Hi.

I have files that should be send out every week. These files changes names e.g. "filename_1" next week it will be "filename_2".

But it only takes the filename that I manually wrote which is filename_1. Is there a way to say that it should take the latest file with this name everyweek,instead of me doing it manually every week?

 

This is my code for the email (I manually wrote the filename): 


filename outbox email
from="test@test.dk"
to="test@test.dk"
type='text/html'
subject='test'
attach=("F:\filename_1.png" ct='png')
ods html body=outbox rs=none style=Htmlblue;run;
ods html close;

 

 

1 REPLY 1
SASJedi
SAS Super FREQ

Use a macro variable to designate the attachment file when you create it. 

For example:

/* Create the attachment file in the WORK library so it will be automatically deleted when the SAS session ends */
%let myFile=%sysfunc(pathname(work))\Report.pdf;
ods pdf body="&myFile" style=Journal; PROC SQL; title "Details from sashelp.class where age > 10"; SELECT * from sashelp.class where age > 10; quit; ods pdf close; /* Set up this email using the PDF created above as an attachment*/ filename mymail email "my.recipient@example.com" subject="Report for sashelp.class" lrecl=256 type="TEXT/HTML" /* Attachment information */ attach="&myFile"; ods html5 body=mymail style=sasweb; options nocenter; title; /* Write the body of the email */ data _null_; file print; put "Here is the information you asked for."; put "May the SAS be with you!"; put "Mark"; run; ods html5 close;

 

Check out my Jedi SAS Tricks for SAS Users

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 609 views
  • 0 likes
  • 2 in conversation