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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ArtC
Rhodochrosite | Level 12

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");

View solution in original post

8 REPLIES 8
ArtC
Rhodochrosite | Level 12

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");
Banu
Obsidian | Level 7

It's working fine. Thanks

Kurt_Bremser
Super User
%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.

Banu
Obsidian | Level 7

Thanks for your sugegstion. It's helpful for me.

Banu
Obsidian | Level 7

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.

 

 

 

Kurt_Bremser
Super User

@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

Banu
Obsidian | Level 7

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?

 

Kurt_Bremser
Super User

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.

sas-innovate-2024.png

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.

 

Register now!

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.

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
  • 3390 views
  • 0 likes
  • 3 in conversation