Dear SAS experts,
May I kindly ask you for help with my code which is used to send email from SAS.
I need help with:
1) How to break line after each ODS HTML TEXT line
2) How to remove boarders around that ODS HTML TEXT within email.
Here is my code:
options emailsys=smtp; options emailauthprotocol=none; options emailhost="xxxxx"; options emailport=xx; filename temp email to = ("xxxxxxx@xxxxxx.xx") subject="xxxxxxxxxx " type="text/html" from = "xxxxxxx@xxxxxxxx.xx"; ODS html body=temp style = noline; ods html text = "Dear,"; PROC REPORT DATA=xxxx nowd HEADLINE HEADSKIP style (report) = {background = white font_face = "Verdana" font_size = 7pt just=left} style (column) = {background = white CELLHEIGHT = 2.5% font_face = "Verdana" font_size = 7pt just=left} style (header) = {foreground = cx5e2750 font_face="Verdana" font_size = 8pt just=left background = white}; run; ods html text = "Best regards,"; ods html text = "XXXXXX XXXXX XX"; ods _all_ close;
If you could make a change inside the code it would be even better.
Thank you very much in advance 😊
If you don't have a need for a lot in-line style overrides I suggest that you try Proc ODSTEXT for something simple;
Proc odstext; p "Best regards,"; p; p "XXXXXX XXXXX XX"; run;
The P is "start new paragraph" so the second one inserts a blank line. By default the proc does not have the text appear with table borders.
Thank you very much @ballardw you don't know how much you saved my day 😊
Now it works good, but I have just one more question.
Outlook creates this gap between first line and table of content.
Do you have any idea how can I reduce it to regular height.
Here is the code I'm using:
ods MSOffice2K body=mymail style=daisy; Proc odstext; p "Dear,"; run; PROC REPORT DATA=xxxx nowd HEADLINE HEADSKIP style (report) = {background = white font_face = "Verdana" font_size = 7pt just=left} style (column) = {background = white CELLHEIGHT = 2.5% font_face = "Verdana" font_size = 7pt just=left} style (header) = {foreground = cx5e2750 font_face="Verdana" font_size = 8pt just=left background = white}; run; Proc odstext; p "Best regards,"; run; ods msoffice2k close;
And here is the output in the Outlook with that gap I mentioned.
As far as I know that gap is typically related to the PARSKIP style element and the suboption VSPACE in the ODS STYLE. At least this is shown with ODS TAGSETS.RTF in the documentation. I have no idea whether it works with the ODS MSOFFICE2k destination or your custom style but you can try:
ods MSOffice2K body=mymail style=daisy options(vspace="NO");
and see what happens.
However, that could affect space between any tables and may have side effects in other than the first place you want it.
It might be possible to change the Vspace setting with ods options in other places with code like this before tables that want the space to reappear. Maybe. This analogous to using options to start new sheets in ODS Excel output for example
ods ms0ffice2k options(vspace='YES');
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 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.