BookmarkSubscribeRSS Feed

When writing email text, it would be nice to be able to package the email text like the other parameters of the emails are packaged.

 

So instead of generating a warning (I have no control of the message contents) with:

%let msg= "<html><h1>P&L Summary</h1>" / "more text" ;
data _null_;
  file _EMAIL ;  
  put &msg. ;
  ... 

I could wrap it like the other email parameters are wrapped:

data _null_;
  file _EMAIL ;
  LINE=symget(msg);
  put '!EM_MESSAGE! ' LINE ;
  ... 

This last example would not generate a

WARNING: Apparent symbolic reference L not resolved.
message.

 

Just an idea...

 

 

10 Comments
Tom
Super User
Super User

I don't understand the proposal. What is the issue that it trying to fix? And how?

Is the issue just with trying to pass in data via a macro variable?  If you want to pass data into your email then pass it as data and not as code fragments.

data _null_;
  file _email ;
  set input_data;
  put '!EM_MESSAGE! ' line ;
run;

Or  are you saying that email directives don't work when you are generating HTML based messages instead of plain text messages?  If so is it a problem for all email directives?

ChrisNZ
Tourmaline | Level 20
put '!EM_MESSAGE! ' line ;

is invalid.

There is no  EM_MESSAGE directive. Hence the proposal that there be one.

 

russt_sas
SAS Employee

You can get rid of the warning by changing the %LET to the following:

 

%let msg= '<html><h1>P&L Summary</h1>' / "more text" ;

 

The double quotes was causing the & to be seen as a macro trigger.  Single quotes causes the & to be seen as just text.

ChrisNZ
Tourmaline | Level 20
I have no control of the message contents
russt_sas
SAS Employee

If you are just worried about the warning, you can run with this OPTIONS statement so those types of warnings are not generated:

 

options noserror nomerror;

ChrisNZ
Tourmaline | Level 20

Thanks @russt_sas.

That's a good idea. However, turning off warnings is frowned upon/disallowed in most production environments these days.

(which makes it all the more urgent to categorise the log messages properly).

Quentin
Super User

If you're trying to mask problematic characters that result from resolving a macro variable, wouldn't %superq be part of the solution?

 

 

1    %let msg= "<html><h1>P&L Summary</h1>" / "more text" ;
WARNING: Apparent symbolic reference L not resolved.
2
3    data _null_ ;
4      line=symget('msg') ;
5      put line ;
6      put "%superq(msg)" ;
7    run ;

"<html><h1>P&L Summary</h1>" / "more text"
"<html><h1>P&L Summary</h1>" / "more text"

That said,  +1 for EM_MESSAGE.

ChrisNZ
Tourmaline | Level 20

The  /  should be interpreted by put as code, i.e. generate new line.

Quentin
Super User

Yeah, I noticed that, that's why I said "part" of the solution. : )

 

I think that would be tricky, even with EM_MESSAGE.  I think is EM_MESSAGE would have to look inside the value and see the / and interpret it, not the PUT statement. As showed with

line=symget('msg');
put line;

once you write a string value into a PDV variable, the PUT statement doesn't see slash or quotes in the string as special characters any more, they're just text. So I think EM_MESSAGE would need to know about quote marks and slashes and other stuff like that.

ChrisNZ
Tourmaline | Level 20

 @Quentin Mmm I think you are right. My case makes no sense. Either the string is code and I have to suffer whatever message is generated, or it is a simple string and no code is run.

Oh well. There might still be value in the suggestion, but not from my example.