I have an ODS HTML table made with Proc Report where I need to add an HTML class attribute to a table row <tr>
, and not each individual <td>
cell in that row. The reason is that this is required in an stickyRow option in the TableSorter jQuery plug-in to keep it from not being sortable as the rest of the table.
The row (a total sum row) is created in a compute statement.
The following statement sets the class to 'static' for each <td>
cell in the row, but not in the <tr>
which is required in the option.
PROC REPORT
compute BEFORE;
&variabel. = 'Totalt';
call define (_ROW_,"style","style={flyover='Totalt' FONT_WEIGHT=bold
background=lightgrey class='static'}");
ENDCOMP;
The HTML resolves to this:
<tr>
<td title="Totalt" class="l static" style=" background-color: #d3d3d3; font-weight: bold;”>T</a></td>
<td title="Totalt" class="r static" style=" background-color: #d3d3d3; font-weight: bold;"> 44,737,223</td>
<td title="Totalt" class="r static" style=" background-color: #d3d3d3; font-weight: bold;"> 43,321,900</td>
Is there a way to set the class as 'static' for the entire <tr>
-row, and not each cell?
The following is what I need it to be like:
<tr class="static">
<td title="Totalt" class="l" style=" background-color: #d3d3d3; font-weight: bold;”>T</a></td>
<td title="Totalt" class="r" style=" background-color: #d3d3d3; font-weight: bold;"> 44,737,223</td>
<td title="Totalt" class="r" style=" background-color: #d3d3d3; font-weight: bold;"> 43,321,900</td>
UPDATED: Here is a reproducible example:
ODS HTML FILE='H:\Temp\demo.html';
ODS HTML TEXT="
<script src='https://code.jquery.com/jquery-3.2.1.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.28.15/js/jquery.tablesorter.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.28.15/js/jquery.tablesorter.widgets.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.28.15/js/widgets/widget-staticRow.min.js'></script>";
ODS HTML TEXT="
<script>
$(function(){
$(document).ready(function() {
$('.table').tablesorter({theme: 'blue', widgets: ['stickyHeaders','zebra','staticRow']});
});
});
</script>";
PROC REPORT DATA=SASHELP.CLASS;
COLUMN SEX AGE N WEIGHT;
DEFINE sex /DISPLAY;
DEFINE age /DISPLAY;
DEFINE weight / ANALYSIS;
RBREAK BEFORE/SUMMARIZE;
COMPUTE before;
CALL DEFINE (_ROW_,"style","style={flyover='Total number and weight' FONT_WEIGHT=bold background=lightgrey class='static'}");
ENDCOMP;
RUN;
ODS HTML CLOSE;