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!
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:
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:
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
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:
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:
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.