sas_enginesetup: Create SAS engines for knitr

sas_enginesetupR Documentation

Create SAS engines for knitr

Description

In addition to knitr's built in SAS engine, this function creates additional engines for SAS. Once created, these engines may be invoked like any other knitr engine to generate different forms of SAS output.

Set up once per session (i.e. document). Ordinarily this is run automatically when SASmarkdown is loaded.

Usage

sas_enginesetup(...)

saslog(options)
sashtml(options)
saspdf(options)

Arguments

...

arguments to be passed to knit_engines$set(...). These take the form enginename=enginefunction

options

options are passed knitr to the engine functions when they are actually invoked within knitr.

Details

This is a convenience function that uses knit_engines$set() to define knitr language engines.

sas_enginesetup(...) passes it's arguments to knit_engines$set() in the form of enginename=enginefunction pairs. Three pre-defined engine functions are in this package: sashtml, saslog, and saspdf. These functions are used as follows.

  • sas_enginesetup(sas=saslog) creates a language engine that returns SAS code, as well as listing output. The engine created is called "sas", and replaces knitr's "sas" engine. This new engine provides better SAS error handling if you set the chunk option error=TRUE.

  • sas_enginesetup(saslog=saslog) creates a language engine that returns SAS log output instead of the plain code that is usually echoed, as well as listing output. The engine created is called "saslog".

  • sas_enginesetup(sashtml=sashtml) creates a language engine that returns SAS html output using SAS's ODS system. The engine created is called "sashtml". An additional side effect is that the html results are used "asis" - you can hide them or you can use them as ordinary document text.

  • sas_enginesetup(sashtmllog=sashtml) creates a language engine that returns SAS log output instead of the plain code that is usually echoed, as well as html output. The engine created is called "sashtmllog".

  • sas_enginesetup(sashtml5=sashtml, sashtml5log=sashtml) create language engines that produce html output with inline images and UTF-8 output

  • sas_enginesetup(saspdf=saspdf, saspdflog=saspdf) create language engines that produce LaTeX output, with inline images

The end user should not need to use the language engine functions directly. These are the workhorse functions that actually call SAS and return output. Their main use is when set up within sas_enginesetup(sashtml=sashtml)

Value

There are no return values for sas_enginesetup, engine creation is a side effect here.

The individual language engine functions return SAS code and SAS output internally to knitr.

Author(s)

Doug Hemken

See Also

knit_engines

Examples

sas_enginesetup(sashtml=sashtml, saslog=saslog)

indoc <- '
---
title: "Basic SASmarkdown Doc"
author: "Doug Hemken"
output: html_document
---
# In a first code chunk, set up with
```{r}
library(SASmarkdown)
```
# Then set up SAS code chunks with
```{sas}
proc means data=sashelp.class;
run;
```
'
if (!is.null(SASmarkdown::find_sas())) {
  # To run this example, remove tempdir().
  fmd <- file.path(tempdir(), "test.md")
  fhtml <- file.path(tempdir(), "test.html")

  knitr::knit(text=indoc, output=fmd)
  rmarkdown::render(fmd, "html_document", fhtml)
}


Hemken/SASmarkdown documentation built on Jan. 14, 2024, 11:26 p.m.