BookmarkSubscribeRSS Feed
Bill_dunno
Calcite | Level 5

I have working code which runs daily and generates an email with an attached excel file. Included in the body of the email are three tables I populate with proc print. We have significant security constraints which don't allow me to create a permanent template of my own, and I have tried for a few days now to get the body of the email in one font, aligned the way I want it through a number of different methods. Ultimately they all turn out ugly.

 

I'm new to ODS work and completely self taught, so I am certain this is not the best way to do it, any help would be appreciated.

 

I've defined the labels in prior steps and the data tables only contain exactly the variables I need to output. I'm using SAS enterprise guide, version 6.100.0.4180, platform version 9.4.2.0. I access it through multiple (2) jump boxes as a virtual machine and that machine has no internet access (not sure if that matters).

 

Here is the code I use;

FY = Fiscal year I'm running it for

RPT_DT = day I'm running the report

 

ODS _ALL_ CLOSE;
filename OUTPUT email
SUBJECT = "FY&FY. Overall results to date for &RPT_DT."
FROM = 'me@mail.com'
TO = 'endUser@mail.com'
CONTENT_TYPE= 'TEXT/HTML' 
ATTACH = "/prjct1/output/secure/Overall &RPT_NM..XLS";

 

ODS HTML BODY=OUTPUT;

 

TITLE JUSTIFY=LEFT "FY&FY. Overall results to date for &RPT_DT.";
PROC PRINT DATA=SUBTOTAL4 LABEL NOOBS SPLIT='|' ;
RUN;


TITLE JUSTIFY=LEFT "FY&futureFY. National Programs detailed results to date for &RPT_DT.";
PROC PRINT DATA=BASELINE_04 LABEL NOOBS SPLIT='|';
WHERE NATIONAL='National';
RUN;


TITLE "FY&FY. Local Programs detailed results to date for &RPT_DT.";
PROC PRINT DATA=BASELINE_04 LABEL NOOBS SPLIT='|';
WHERE NATIONAL='Local';
RUN;
ODS _ALL_ CLOSE;

 

This code outputs correctly, but its not formatted the way I would like. I've attached a partial screenshot of the output.

Capture output.JPG

 

I'd like to do a number of things... 

  • I would like to get the font and font size to be the same throughout. The Titles are appearing as 10pt Arial, the proc prints are 12pt Times New Roman
  • I'd like to align the printed tables (not their contents) to the left (you'll see in the image the overall results, a smaller table, is centered/indented, while the national is a larger table and fills the email to both margins and I am guessing also centered, but because its larger it begins at the left margin.

Less important, but I feel like I should be able to do these...

  • I would like to put in some introductory text before I output the title and tables
  • I'd like to remove the boxes around the titles
  • I'd like to put a (boxless) footer at the bottom (I am able to do so using the code below, but it shows up as boxed

ODS HTML TEXT = " ";
ODS HTML TEXT = "Corporate Analytics - &RPT_DT.";
ODS HTML TEXT = " ";
ODS HTML TEXT = "NOTICE: This e-mail (and any attachments) may be confidential and proprietary. It is for the sole use of the intended recipient(s) and any use or disclosure by others is prohibited. If you are not the intended recipient(s), please notify the sender by return e-mail and delete all copies of this e-mail (and any attachments).";
ODS HTML CLOSE;

 

Thank you,

Bill

 

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

> I would like to get the font and font size to be the same throughout.   

   google this: proc print style

 

> I'd like to align the printed tables (not their contents) to the left 

   Try:  option nocenter;

 

I think your other concerns are more difficult to address, requiring changing ODS styles.

Try:  ODS html style=default  I think it doesn't box titles. 

 

If you find no style that suits your needs you may have to modify the styles.

Mar1ene
Obsidian | Level 7

 

Hi Bill,

 

This is what I use to format my emails:

ods html3 body=OUTPUT

style=htmlblue;
ods escapechar='^';
ODS TEXT="^S={font_face='Calibri' font_size=3 fontweight=Medium foreground=black} ";

 

To create table Title/Footnotes:

 

proc print data=Table_Name noobs;
VAR Loan_Purpose Pricing Loan_Amount n;
format loan_amount comma20.;
TITLE "TABLE TITLE";
Footnote1 "Lotter is based on Male population";
Footnote2 "Average shoe price just over R1k";
run;

 

Mar1ene

 

SAS example.jpg

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 9454 views
  • 4 likes
  • 3 in conversation