BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
a_ramos
Obsidian | Level 7

/* Table with email and names */
DATA NAMES;
INFILE DATALINES DELIMITER='|';
FORMAT EMAIL $CHAR23. NAME $CHAR5. CODE $CHAR10.;
INPUT EMAIL $ NAME $ CODE $;
DATALINES;
email.1@test.com|Name1|1111, 2020
email.2@test.com|Name2|1000, 2026
email.3@test.com|Name3|1008, 2096
;

/* Emails that will be sent in copy */
PROC SQL NOPRINT;
SELECT DISTINCT CAT('"',TRIM(EMAIL),'"') INTO: LISTA SEPARATED BY ' ' FROM NAMES;
QUIT;

/* Email */
%LET DIA=%SYSFUNC(TODAY());
%LET NDIA=%SYSFUNC(INTNX(DAY,&DIA,-1,B),DDMMYY10.);

FILENAME REPORT ".../REPORT.html";
FILENAME CODE
EMAIL "email@test.com"
CC=(&LISTA)
CONTENT_TYPE="text/html"
SUBJECT="Title &NDIA."
ATTACH=(".../archive.xlsx" CONTENT_TYPE="application/xlsx");

/* HTML Report File */
ODS HTML FILE=REPORT;
ODS NOPTITLE NOPROCTITLE;

PROC REPORT DATA=NAMES(DROP=EMAIL) NOWD HEADLINE HEADSKIP
STYLE (REPORT) = {BACKGROUND = WHITE FONT_SIZE = 8PT
FONT_FACE = "Calibri" FONT_SIZE = 9PT JUST=LEFT}

STYLE (COLUMN) = {BACKGROUND = WHITE CELLHEIGHT = 3.5%
FONT_FACE = "Calibri" FONT_SIZE = 9PT JUST=LEFT}

STYLE (HEADER) = {FOREGROUND = CXFF8C00 FONT_FACE="Calibri"
FONT_SIZE = 10PT JUST=LEFT
BACKGROUND = WHITE} ;
RUN;

ODS HTML CLOSE;

/* HTML edited for me */
FILENAME ETL '.../ETL.html';

/* Incorrect */
DATA _NULL_;
INFILE ETL;
FILE ETL2;
INPUT;
PUT _INFILE_;

INFILE REPORT;
FILE ETL2;
INPUT;
PUT _INFILE_;
RUN;

 

It is something like concatenating files. But the files are in HTML.
Basically, I want to include a few lines from one HTML file to another while keeping your writing

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You can't "just append" lines to a HTML file. The file ends with a </html> directive, and everything after that will be outside the logical HTML data.

To add content to HTML created by ODS, you neet to use no_bottom_matter in the ODS HTML CLOSE, and after writing content to the file (use a file reference with mod), add another ODS HTML with no_top_matter, and an ordinary ODS HTML CLOSE.

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

It is hard to see the question in the mash of unformatted code.

But it sounds like you are asking for the MOD option on the FILE statement.  With that new lines are written to the end of the file. Without that the file is made new (any existing file is removed/replaced).

Kurt_Bremser
Super User

You can't "just append" lines to a HTML file. The file ends with a </html> directive, and everything after that will be outside the logical HTML data.

To add content to HTML created by ODS, you neet to use no_bottom_matter in the ODS HTML CLOSE, and after writing content to the file (use a file reference with mod), add another ODS HTML with no_top_matter, and an ordinary ODS HTML CLOSE.

a_ramos
Obsidian | Level 7

Hi, thanks for responding and for the solution.

 

I did the following:

 

/* I used PROC TEMPLATE to remove the original CSS style */

PROC TEMPLATE;
DEFINE TAGSET TAGSET.CUSTOM;
PARENT=TAGSETS.HTML4;
EMBEDDED_STYLESHEET=OFF;
END;

 

/* Output table for the email body in an HTML file */

ODS TAGSET.CUSTOM FILE=REPORT;
ODS NOPTITLE NOPROCTITLE;

PROC REPORT DATA=NAMES(DROP=EMAIL) NOWD HEADLINE HEADSKIP RUN;
ODS TAGSET.CUSTOM CLOSE;

 

/* I created a new HTLM file, creating my own CSS style and HTML text using  IF _INFILE_ =: '<body' and IF _INFILE_ =: '<head */

DATA _NULL_;
INFILE REPORT;
FILE MSG;
INPUT;
PUT _INFILE_;
IF _INFILE_ =: '<head' THEN DO;
PUT '<style type="text/css">
*,
*:after,
*::before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

body {
background:#fff;
color:#000;
font-family:Verdana,sans-serif;
margin:0;
padding:0;
}

header {
border-top: 5px solid #00ff17;
}

h1, h2, h3, p{
font-weight: normal;
margin:5px 10px;
}

h1{
font-family: Verdana,sans-serif;
font-size: 1.5em;
}

h1.topo {
padding: 20px 10px;
text-transform: uppercase;
}

p {
font-size:1em;
}

table {
margin:0 auto;
width:80%;
}

thead{
color:#17d615;
}

table, th, thead{
border: none;
background:#282828;
}

td {
border-bottom: 1px solid #282828;
font-size:0.8em;
background:#f6f6f6;
}

td.r.data {
text-align: center;
}

ul {
list-style-type: circle;
font-size:1em;
}

</style>';
END;

IF _INFILE_ =: '<body' THEN DO;
PUT '
<header>
<h1 class="topo"> LOREM INPSUM DOLOR </h1>
</header>
<p style="color:#00d318;">Lorem ipsum dolor sit amet:</p>
<ul>
<li>Consectetur adipiscing elit, sed do eiusmod tempor incididunt;</li>
<li>Excepteur sint occaecat cupidatat non proident.</li>
</ul>

<p>Sunt in culpa qui officia deserunt mollit anim id est laborum:</p>
</br>
';
END;
RUN;

 

/* Finally, I put the html file as the body of the email */

DATA _NULL_;
INFILE MSG;
FILE CODE;
INPUT;
PUT _INFILE_;
RUN;

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 652 views
  • 2 likes
  • 3 in conversation