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

Hi everyone,

I need some help; I need to write a code that will send an email and I need it to have some tables. Using PROC REPORT works well enought when it's a single one, but when I add the second, a page break is inserted that ends up messing the layout.

 

ODS _ALL_ CLOSE;

OPTIONS EMAILSYS=smtp;
OPTIONS EMAILAUTHPROTOCOL=none;
OPTIONS EMAILHOST="smtp.mail.com";
OPTIONS EMAILPORT=25;

FILENAME myemail EMAIL
TO = ("recipient@mail.com")
FROM = ("sender@mail.com")
TYPE = 'text/html'
SUBJECT = "Reports";

ODS HTML BODY=myemail STYLE=EGDefault;

/* Email text */
ODS HTML TEXT = '<p>Greetings,</p>';
ODS HTML TEXT = '<p>Here are the results on this week.</p>';
ODS HTML TEXT = '<p style="font-size:16px; font-style: italic">Report 1</p>';
/* First Report */ PROC REPORT DATA=sashelp.class; RUN;
/* Back to the email */ ODS HTML TEXT = '<span>Some more text.</span>'; ODS HTML TEXT = '<p style="font-size:16px; font-style: italic">Report 2</p>';
/* Second Report */ PROC REPORT DATA=sashelp.class; RUN;

/* Finishing the email */ ODS HTML TEXT = 'That is all, best regards';
ODS _ALL_ CLOSE;

Has anyone had this problem and found a solution?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Your Style of EGDEFAULT, inherits this CSS "page break" between procedures from the DEFAULT style template used for HTML. The DEFAULT style template has this HTML style element or class:

style_html_page_break.png

Note that the page-break-after: always is a CSS style command that is being added to the <p> tag that will be inserted between procedures.

 

  One way around this is to create all your reports in one RTF or PDF file (or even an HTML file, but some mail systems don't like to accept HTML files as attachments) and then write your message in a DATA step, but attach the reports as a separate attachment without writing them to HTML message body directly. That method is shown in this paper http://support.sas.com/resources/papers/proceedings11/300-2011.pdf on page 7:

send_attach.png

 

The other option is to try OTHER styles (not EGDEFAULT) that don't inherit from STYLES.DEFAULT and see whether they work better for you. Some styles to try are NORMAL or MEADOW. They only use a standard <br/> between procedures as the "page-break".

 

The final and probably most difficult option is to create your own style template and modify the html section to avoid using page-break-after: always.

 

Hope this helps,

cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  Your Style of EGDEFAULT, inherits this CSS "page break" between procedures from the DEFAULT style template used for HTML. The DEFAULT style template has this HTML style element or class:

style_html_page_break.png

Note that the page-break-after: always is a CSS style command that is being added to the <p> tag that will be inserted between procedures.

 

  One way around this is to create all your reports in one RTF or PDF file (or even an HTML file, but some mail systems don't like to accept HTML files as attachments) and then write your message in a DATA step, but attach the reports as a separate attachment without writing them to HTML message body directly. That method is shown in this paper http://support.sas.com/resources/papers/proceedings11/300-2011.pdf on page 7:

send_attach.png

 

The other option is to try OTHER styles (not EGDEFAULT) that don't inherit from STYLES.DEFAULT and see whether they work better for you. Some styles to try are NORMAL or MEADOW. They only use a standard <br/> between procedures as the "page-break".

 

The final and probably most difficult option is to create your own style template and modify the html section to avoid using page-break-after: always.

 

Hope this helps,

cynthia

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 25. 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
  • 1 reply
  • 3699 views
  • 0 likes
  • 2 in conversation