4 SAS HTML output

SAS can produce output in several different formats. The traditional SAS output, "listing" output, is written as plain text. This means that "tables" depend on mono-spaced fonts and the width of the end user's screen to display properly. It also makes it more work to include graphics in your document.

However, the SAS Output Delivery System (ODS) makes it easy to produce HTML output. Using HTML output from SAS makes it easy to have tables that retain their structure despite variations in end user fonts and screen sizes. And HTML output makes it easy to include graphics in documents.

4.1 Set up

This is set up by using a different "language engine" in knitr. The initial document setup using the SASmarkdown package is the same.

library(SASmarkdown)

4.2 Using the 'sashtml' engine

Invoke the sashtml engine for code chunks. What you write is:

```{sashtml} 
proc corr data=sashelp.class plots=matrix;
run;
```

This produces:

proc corr data=sashelp.class plots=matrix;
run;
3 Variables: Age Height Weight
Simple Statistics
Variable N Mean Std Dev Sum Minimum Maximum
Age 19 13.31579 1.49267 253.00000 11.00000 16.00000
Height 19 62.33684 5.12708 1184 51.30000 72.00000
Weight 19 100.02632 22.77393 1901 50.50000 150.00000
Pearson Correlation Coefficients, N = 19
Prob > |r| under H0: Rho=0
  Age Height Weight
Age
1.00000
 
0.81143
<.0001
0.74089
0.0003
Height
0.81143
<.0001
1.00000
 
0.87779
<.0001
Weight
0.74089
0.0003
0.87779
<.0001
1.00000
 
Scatter Plot Matrix Scatter Plot Matrix 60 80 100 120 140 50 55 60 65 70 11 12 13 14 15 16 60 80 100 120 140 50 55 60 65 70 11 12 13 14 15 16 Weight Height Age

The default SASmarkdown “style” for HTML and HTML5 output is journal. To invoke a different SAS “style”, specify it with:

```{sashtml5 style_example, saveSAS=TRUE} 
ods html5 style=htmlblue;
proc corr data=sashelp.class plots=matrix;
run;
```
to produce:
3 Variables: Age Height Weight
Simple Statistics
Variable N Mean Std Dev Sum Minimum Maximum
Age 19 13.31579 1.49267 253.00000 11.00000 16.00000
Height 19 62.33684 5.12708 1184 51.30000 72.00000
Weight 19 100.02632 22.77393 1901 50.50000 150.00000
Pearson Correlation Coefficients, N = 19
Prob > |r| under H0: Rho=0
  Age Height Weight
Age
1.00000
 
0.81143
<.0001
0.74089
0.0003
Height
0.81143
<.0001
1.00000
 
0.87779
<.0001
Weight
0.74089
0.0003
0.87779
<.0001
1.00000
 
Scatter Plot Matrix Scatter Plot Matrix 60 80 100 120 140 50 55 60 65 70 11 12 13 14 15 16 60 80 100 120 140 50 55 60 65 70 11 12 13 14 15 16 Weight Height Age

Use

```{sas} 
proc template;
list styles / store=sashelp.tmplmst;
run;
```

To see a list of SAS HTML styles.

4.3 Using the 'sashtml5' engine

If you use the sashtml5 engine, your graphs are embedded within your HTML file, rather than being stored as separate image files. This can make file management easier.

Written using

  • SASmarkdown version 0.8.0.
  • knitr version 1.40.
  • R version 4.2.2 (2022-10-31 ucrt).