SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Jorge_Silva
Fluorite | Level 6

Hi.

I'm sending an automatic email using SAS with ODS html where I add the text using proc odstext.

In the email I'm trying to insert an indented paragraph, however without any success. Here's a sample of what I have:

proc odstext;
p "<font face='Arial' size='2'>What I have. </font>';
run;

Result: What I have.


proc odstext;
p "<font face='Arial' size='2' Ind = "1.25cm" >What I want. </font>';
run;

Expected result:        What I want. (with 1.25 cm indentation)

The code above with ind option does not return errors but it also doesn't indent the paragraph. Is it possible to indent paragraphs here?

Thanks.

 

11 REPLIES 11
ChrisNZ
Tourmaline | Level 20

Is IND= a valid HTML style, or are you making up syntax as you go? 

 

Something like  style='margin:1.25cm'  should work.

 

Also your quotes are wrong.

 

Jorge_Silva
Fluorite | Level 6

Hi Chris.

Thank you for your answer.

I'm making up the syntax, but as I said it runs without errors but also it doesn't indent. 

Tried with your suggestion and it's not indenting. I've tried with the following syntax:

 

proc odstext;
p "<font face='Arial' size='2' style="margin:1.25cm">What I want. </font>';
run;

Don't know if it is the correct syntax.

The quotes are ok, you can start with "" and then use '' in the parameters or start with '' and use "" in the parameters. 

Thanks,

Jorge

 

 

ChrisNZ
Tourmaline | Level 20
Yes browsers don't throw errors when they encounter invalid syntax. I tested the code I provided, so it works.
Jorge_Silva
Fluorite | Level 6

Can you please share the code you used?

 

Thanks.

ChrisNZ
Tourmaline | Level 20

1. Do not make up and invent syntax, that's bonkers. Read the documentation

2. Your quotes are unbalanced

3. This works:

proc odstext;
  p "<font face='Arial' size='2'>What I have. </font>";
  p "<font face='Arial' size='2' style='margin:1.25cm; color:red'>What I have. </font>";
run;

ChrisNZ_0-1621072500937.png

 

 

Jorge_Silva
Fluorite | Level 6

Hi.

I just made the code to give clues about what I was looking for.

Anyway, using the code you shared and using also the color option, the indentation is still not working however the color works. Don't know why this happens.

I'm using the proc odstext inside a macro, maybe that's why it's not working.

Thanks.

Cynthia_sas
SAS Super FREQ

Hi:

  As illustrated in the posted example, the code DOES work to do an indent. The question is when you use the code, where does it NOT work. Have you tested the code as standalone ODS HTML code without using email? Does it work there? When you test it using email, does it work there when the email is opened? Do you have errors in the log? How are you sending the mail - -with the HTML in the body of the mail text or with the HTML file as an attachment. In my experience, sometimes HTML is prohibited by mail systems and formatting and links can be lost. I seriously doubt it is your macro program that is causing the issues, but you have not provided any concrete examples. I recommend trying the simplest example without macro and to a standalone HTML file without email and see whether that works for you. Then go forward from there.

Cynthia

 

ChrisNZ
Tourmaline | Level 20

The macro language is mostly a text generator, so I doubt that's the reason. On top of all of @Cynthia_sas 's recommendations (especially: to isolate a problem, start small, and add the required features until the issue is triggered), I'd advise you to look at your quotes, since you were convinced they were balanced. Also examine your log report carefully.

Jorge_Silva
Fluorite | Level 6

Hi.

Thank you both for your answers.

What I meant is that the code is not working for my purpose, that doesn't mean that is not working as a stand alone. As I also said, I tried to use the color option and it worked just fine in the email.

The email is being sent correctly, there are no errors while running or in the log and the quotes are ok, maybe they're not ok when I created the piece of code to exemplify here. If I use the code sent by Chris it writes the paragraph in red however is not intending. But the indentation is just a small detail in the email, the process is running and the email is being sent, it is just a matter of looking better.

I really appreciate your thoughts and time spent in this topic.

 

ChrisNZ
Tourmaline | Level 20

The HTML generated is the same when using the HTML destination, regardless of whether the body is a file or an email :

<div class="l paragraph"><font face="Arial" size="2">What I have. </font></div>
<div class="l paragraph"><font face="Arial" size="2" style="margin:1.25cm; color:red">What I have. </font></div>

So it looks like Outlook is a defective HTML renderer, which will surprise ... no one.

You need to search which parts of HTML (CSS really) Outlook renders correctly, or if worse comes to worse you can also always add non-breaking spaces.

Jorge_Silva
Fluorite | Level 6

Thanks Chris.

I'll take a look.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 2547 views
  • 3 likes
  • 3 in conversation