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

Hi,

 

 

I am finding myself in a tight corner, and I would really appreciate your help. 

 

Question : How can I assign text with paragraphs(CR LF) to a SAS Macro Variable? 

 

Short story: I am currently working on a generic solution for sending e-mails from SAS.  This should be in a form of a macro : %SendMail(To,From,Subject,Body ... ) . The user should only call the macro and feed the proper parameters.

All is good until you realize that the e-mail body will contain long text with paragraphs (i.e. CR LR) .  

 

How can I assign a text with paragraphs to a macro variable ? 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

There is nothing stopping you from putting CR and LF into macro variables.  For example.

data _null_;
  call symputx('email_message',cats('Line one.','0D0A'x,'Line two.'));
run;
%let email_message=%superq(email_message);

But it would probably be easier for the user and for your coding if you just told them to replace the paragraph marks with some fixed printable character or series of characters.

%let email_message=Line one.|Line two.;

Then your program can replace them with paragraph marks when it generates the email.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

There is nothing stopping you from putting CR and LF into macro variables.  For example.

data _null_;
  call symputx('email_message',cats('Line one.','0D0A'x,'Line two.'));
run;
%let email_message=%superq(email_message);

But it would probably be easier for the user and for your coding if you just told them to replace the paragraph marks with some fixed printable character or series of characters.

%let email_message=Line one.|Line two.;

Then your program can replace them with paragraph marks when it generates the email.

urs
Calcite | Level 5 urs
Calcite | Level 5
Thank you Tom.

Setting up a convention on how to build e-mail bodies should do the trick.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 2053 views
  • 1 like
  • 2 in conversation