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.
I'd like to do a number of things...
Less important, but I feel like I should be able to do these...
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
> 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.
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 Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.