Skip to contents

A SAS engine for knitr

Usage

sas_engine(options)

Arguments

options

Options from knitr.

Value

knitr engine output.

Details

Will be activated by running library(sasquatch)

Supported knitr chunk options

sasquatch's engine implements may of the same options as the R engine in knitr, but not all.

  • eval (Default: TRUE): Evaluate the code chunk (if false, just echos the code into the output)

  • echo (Default: TRUE): Include the source code in output

  • output (Default: TRUE): Include the results of executing the code in the output (TRUE or FALSE).

  • include (Default: TRUE): Include any output (code or results).

  • capture (Default: "both"): If "both", tabpanel with output and log included. If "lst", only output is included. If "log" only log is included.

HTML formats vs all others

SAS has native support for HTML output, which means embeding HTML SAS output within HTML quarto formats is quite easy. You can expect that HTML formats will look nearly identically to how you would expect within a SAS environment.

Within non-HTML formats (pdf, typst, docx), embeding HTML SAS output is not an option. Thus, the engine first renders output to HTML3 and transforms it with the Python package markdownify.

This process is by no means perfect, but in order to use it ensure that markdownify has been installed (install_saspy() will install markdownify for you) AND set a temporary directory to write to within the SAS client, which can be set by sas_set_tempdir().

Credit for this idea goes to fsmunoz within this SASPy discussion post.

Examples

# The below function is run internally within `sasquatch` on startup
knitr::knit_engines$set(sas = sas_engine)

# If rendering to non-HTML formats, set the SAS temporary directory
sas_set_tempdir("~/tempdir")