I need to insert today's date 09/18/2014 in the email subject line. The email subject line would be "Reports for 09/18/2014". Any help is greatly appreciated.
You can use a %let statement to create the date and then call it within your subject line.
FILENAME MailBox EMAIL ATTACH='TestFile';
%LET DATE = %sysfunc( putn( %sysfunc( date() ), MMDDYY10. ));
%Put &DATE;
DATA _NULL_;
FILE Mailbox TO=('Someone@somwhere.com')
SUBJECT = "Test&Date" ;
PUT "Test Test Test";
RUN;
Would something like below work?
data _null_;
call symputx("today",put(today(),mmddyy10.));
run;
%put today=&today;
options emailsys=smtp emailhost=youremailhost emailport=xx;
filename mailbox email "hima@xyz.com";
data _null_;
file MailBox TO=("hima@xyz.com" )
CC=("XXX@xyz.com")
SUBJECT="Reports for &today.";
put "Attached are today's reports";
put "Reply with any questions.";
run;
You can use a %let statement to create the date and then call it within your subject line.
FILENAME MailBox EMAIL ATTACH='TestFile';
%LET DATE = %sysfunc( putn( %sysfunc( date() ), MMDDYY10. ));
%Put &DATE;
DATA _NULL_;
FILE Mailbox TO=('Someone@somwhere.com')
SUBJECT = "Test&Date" ;
PUT "Test Test Test";
RUN;
How about SUBJECT = "Report for &sysdate"?
Needs no other code, and avoids the problem of MMDDYY and DDMMYY confusion for situations when both MM and DD are <= 12 - the first 12 days of every month.
Bill
I see two issues:
1)Small issue: the format.Solutions involving putn or put go extra miles just to get the format OP asked for.
2)Big issue: &sysdate is the date when your current SAS process fired up, which is not necessarily 'today' , per se.
Regards,
Haikuo
As we move to more and more global applications, the OP request may need to take second place to a format that can't be confused.
You are correct about the big issue - although it's not a problem for batch processing, which is what I had in mind.
"although it's not a problem for batch processing, which is what I had in mind."
Batch or not, 'sysdate' is still the date when you start up your current batch. It remains the same issue (not being 'today') if your batch runs across the mid-night or as long as the date of the 'email' is not the same as the date when you start your SAS session (batch or interactive).
my2cents,
Haikuo
This is what I'm using:
data age;
set members14to15;
format today DATETIME22.3;
today = today();
year = year(today());
age = year - year(datepart(birth_date));
if birth_date > today then age=age-1;
run;
I need the age of a member based on their birth date. The problem is - if a person has NOT had their birthday this year, it's still calculating as if they had. Does this help?
Didn't mean to post here. Sorry.
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.
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.