Hi,
My exact task is, I have to show few data values which needs to take values from SAS tables using SAS macro variables and should show in email body. And below is the email smaple body.
Mail body required;
Report for April 2017, the total sales amount is 90,500.50.
In these, Electronics amount is 20,500 and other business area amountsare (50,300.50), and (20,000.10).
Caustion:
All above information is strictly confidentail and not sharable.
To do this, I just started below code and then trying to execute below code but macro variables are not resolved in email using X command. Please suggets me how can we achieve above task
data _null_;
x=today();
y=put(x,date9.);
put y;
call symput('getdate',y);
run;
%put &getdate;
%sysexec export rundate=&getdate;
%sysexec echo $rundate;
x 'echo "Run monthly job only on &getdate." | mailx -s "Mail Notification" banu.kumar@xxxxx.com;
Are you sure that &GETDATE never resolves - not even in the %PUT?
In the X statement you have a mismatched single quote. Also you cannot surround a macro reference with a single quote and still get resolution. There are several ways to get around this, try this general form of the X statement:
x %tslit(echo "&getdate");
Are you sure that &GETDATE never resolves - not even in the %PUT?
In the X statement you have a mismatched single quote. Also you cannot surround a macro reference with a single quote and still get resolution. There are several ways to get around this, try this general form of the X statement:
x %tslit(echo "&getdate");
It's working fine. Thanks
%sysexec export rundate=&getdate; %sysexec echo $rundate;
Both of these commands start a shell; since the change in the environment (new environment variable rundate) is lost when the first shell terminates, the second command won't find $rundate.
Only certain UNIX commands (cd, pwd, setenv, umask) are executed so that they have effect in the context of the SAS session itself.
Thanks for your sugegstion. It's helpful for me.
Is there any option to bold values in echo command in SAS X statement.
x %tslit(echo "Total sales amount is: $500,200.10");
OUTPUT require as: Total sales amount is: $500,200.10
Please suggest me.
@Banu wrote:
Is there any option to bold values in echo command in SAS X statement.
x %tslit(echo "Total sales amount is: $500,200.10");
OUTPUT require as: Total sales amount is: $500,200.10
Please suggest me.
No. echo is a UNIX commandline command that can only handle pure text, without any formatting. Also keep in mind that a data step used to create a mail message (using filename email) can only handle text.
But you can use that data step to write HTML code into the mail, which allows you to use HTML formatting tags. An example for this can be found in http://support.sas.com/resources/papers/proceedings10/060-2010.pdf
I have tried same as you mentioned, but getting "ERROR: Email: The connection was refused."
I have given options like emailhost and emailsys. Any suggestions on this?
So your first task should be to make a very simple, "hello world" type mail work with filename email.
"Connection refused" might indicate that
- there is no SMTP server active on the host you named
- it requires credentials
- it only accepts connections from certain clients
Check with your mail administrator how to access the SMTP server.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.