As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


PROC REPORT Quick Style Change Using HEADTEXT

From sasCommunity
Jump to: navigation, search

When creating HTML output using ODS HTML, it might be necessary to make a minor STYLE change. Instead of resorting to PROC TEMPLATE, you can use the HEADTEXT option in the ODS HTML statement. For example, the underlining of links on an HTML page is a browser setting (TOOLS/OPTIONS/CONTENT/COLORS in Firefox, TOOLS/INTERNET OPTIONS/ADVANCED in Internet Explorer). What if you wanted to turn off the underlining of links regardless of a user's browser setting.

Here is an example that uses the SASHELP.CLASS data set and PROC REPORT to create HTML output ...

ods listing close;
ods results off;
ods html file="z:\nounderline.html" ;
title1 bold color=green height=5 font=Arial bcolor=white 'TEST TITLE1';
 
proc report data=sashelp.class nowd
     split='\' style(report)={cellwidth=4in borderwidth=1pt}
     style(header)={just=left};
columns name sex;
define name /group 'Name' style(column)={bordertopcolor=white
                          borderleftcolor=white borderrightcolor=black
                          borderbottomcolor=black} ; 
define sex / group noprint;
compute sex;
    href=catt('c:/block/',sex,'.htm"',' style="text-decoration:none');
    call define ('name','URL',href);
endcomp;
run;
 
ods html close;
ods results on;
ods listing;

If you look in the COMPUTE block (COMPUTE SEX;), you will see that a STYLE is added to each link in the file. This works, but there is a better way. Just change the ODS HTML statement ...

ods html file="z:\nounderline.html" 
    headtext='<style type="text/css"> a { text-decoration:none } </style>' ;

and remove the STYLE definition from the COMPUTE block ...

compute sex;
    href=catt('c:/block/',sex,'.htm');
    call define ('name','URL',href);
endcomp;

In the HTML output, the appearance of the STYLE definition in the <HEAD> section will eliminate the underlining of links. That instruction is now only in one place in the HTML file rather than appearing within each link.

If you have any questions about this posting, you are welcome to send me a note by clicking here ... email Mike. To see my other SAS Community postings click here.