Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!

Formatting Email Spacing Between Text and Reports

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Formatting Email Spacing Between Text and Reports

Greetings from Minnesota;

 

I am sending an email via SAS code, and I am having some trouble with some of the formatting.

 

I successfully figured out how to put text, then a report, and then more text into the email; moreover, I added a PROC FORMAT to modify a STYLE to remove borders and unnecessary style effects from my text. However, there are large gaps (spacings, margins, etc. - I'm not sure of the proper term) before and after my "opening" and "closing" texts. Is there a way to collapse these large spaces to produce a much shorter email body?

 

My Code

PROC TEMPLATE;
  DEFINE STYLE STYLES.SASWEBMOD;
    PARENT=STYLES.SASWEB;
      CLASS SYSTITLEANDFOOTERCONTAINER / HTMLSTYLE="BORDER:NONE";
  END;
RUN;

FILENAME MYMAIL EMAIL
  FROM          = "JOHN_DOE@COMPANY.COM"
  TO            = "JOHN_DOE@COMPANY.COM"
  SUBJECT       = "TEST EMAIL SUBJECT"
  CONTENT_TYPE  = "TEXT/HTML";

ODS _ALL_ CLOSE;
ODS HTML3 BODY=MYMAIL RS=NONE STYLE=SASWEBMOD;
OPTIONS NOCENTER;

/*OPENING TEXT*/
DATA _NULL_;
   FILE PRINT;
PUT  "The text that precedes the SAS Report goes here.";
RUN;

/*REPORT*/
TITLE1 "SAS Report header goes here.";
PROC REPORT DATA = SASHELP.CLASS(OBS=5);
  COLUMNS _ALL_;
  DEFINE  _ALL_    / DISPLAY CENTER;
RUN;
TITLE;

/*CLOSING TEXT*/
DATA _NULL_;
   FILE PRINT;
PUT  "The text that proceeds the SAS Report goes here.";
RUN;

ODS _ALL_ CLOSE; 
ODS LISTING; 

 

 

Sample Output

 

 EmailExample.JPG

 

Thanks in advance for your help!


Accepted Solutions
Solution
‎07-09-2018 12:55 PM
SAS Super FREQ
Posts: 9,436

Re: Formatting Email Spacing Between Text and Reports

Posted in reply to DanielJForman

Hi:
  I typically send email as an attachment because many companies don't allow email with HTML in the body of the mail or they convert the HTML to plain text before delivery. With an attachment of the report as a PDF or RTF file, I am more sure that the mail will go through the system unchanged.

I see that you're using ODS HTML3 -- that is older HTML destination. You're getting a logical PAGE break (that horizontal rule is an HTML indicator of a page break) between each of your outputs because of the DATA _NULL_ steps. Have you considered using ODS TEXT=. I did not send an email, but I created output with the following code (using your same template):

ODS _ALL_ CLOSE;
ODS PDF BODY="c:\temp" FILE="usetext_acro.pdf" STYLE=SASWEBMOD startpage=no;
ODS HTML4 BODY="c:\temp" FILE="usetext_ht4.html" RS=NONE STYLE=SASWEBMOD;
ODS HTML3 BODY="c:\temp" FILE="usetext_ht3.html" RS=NONE STYLE=SASWEBMOD;
OPTIONS NOCENTER;

/*OPENING TEXT*/
ods text="The text that precedes the SAS Report goes here.";
 

/*REPORT*/
TITLE1 "SAS Report header goes here.";
PROC REPORT DATA = SASHELP.CLASS(OBS=5);
  COLUMNS _ALL_;
  DEFINE  _ALL_    / DISPLAY CENTER;
RUN;
TITLE;

/*CLOSING TEXT*/
ods text="The text that follows the SAS Report goes here.";
 

ODS _ALL_ CLOSE; 
ODS LISTING; 

 

and got these results in the HTML3 output file:

use_ods_text_examp.png

 

Cynthia

View solution in original post


All Replies
Solution
‎07-09-2018 12:55 PM
SAS Super FREQ
Posts: 9,436

Re: Formatting Email Spacing Between Text and Reports

Posted in reply to DanielJForman

Hi:
  I typically send email as an attachment because many companies don't allow email with HTML in the body of the mail or they convert the HTML to plain text before delivery. With an attachment of the report as a PDF or RTF file, I am more sure that the mail will go through the system unchanged.

I see that you're using ODS HTML3 -- that is older HTML destination. You're getting a logical PAGE break (that horizontal rule is an HTML indicator of a page break) between each of your outputs because of the DATA _NULL_ steps. Have you considered using ODS TEXT=. I did not send an email, but I created output with the following code (using your same template):

ODS _ALL_ CLOSE;
ODS PDF BODY="c:\temp" FILE="usetext_acro.pdf" STYLE=SASWEBMOD startpage=no;
ODS HTML4 BODY="c:\temp" FILE="usetext_ht4.html" RS=NONE STYLE=SASWEBMOD;
ODS HTML3 BODY="c:\temp" FILE="usetext_ht3.html" RS=NONE STYLE=SASWEBMOD;
OPTIONS NOCENTER;

/*OPENING TEXT*/
ods text="The text that precedes the SAS Report goes here.";
 

/*REPORT*/
TITLE1 "SAS Report header goes here.";
PROC REPORT DATA = SASHELP.CLASS(OBS=5);
  COLUMNS _ALL_;
  DEFINE  _ALL_    / DISPLAY CENTER;
RUN;
TITLE;

/*CLOSING TEXT*/
ods text="The text that follows the SAS Report goes here.";
 

ODS _ALL_ CLOSE; 
ODS LISTING; 

 

and got these results in the HTML3 output file:

use_ods_text_examp.png

 

Cynthia

New Contributor
Posts: 3

Re: Formatting Email Spacing Between Text and Reports

Posted in reply to Cynthia_sas
Thank you, Cynthia. All I needed to do was swap out my DATA _NULL_ statements for ODS TEXT = " ". It worked perfectly.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 130 views
  • 0 likes
  • 2 in conversation