try(detach("package:SASmarkdown"), silent=TRUE)
spinsas
is an alternative way of processing dynamic Markdown
from a SAS command file. In this form, documents are written
within the comments of a SAS file. This enables you to
run the same file within SAS (to simply execute the commands) and
through knitr
(to produce Markdown and HTML files).
This is particularly useful if you already have a number of *.sas files to which you\'d like to add a little text to produce a document.
Within your SAS command file (*.sas), you use the following symbols to denote plain Markdown text, SAS code chunks, R code chunks, and text to be dropped from the document.
Notice that SAS will treat all of these as comments.
In order to run SAS code, first we load the SASmarkdown
library so it can automatically set up some necessary options in R.
*+ setup, message=FALSE ; *R library(SASmarkdown) ;
Text is then included as a special comment.
** The report begins here.;
Finally, the executable SAS code is given a line of chunk instructions.
*+ example1, engine='sas', comment=NA; proc means data=sashelp.class /*(keep = age)*/; run; /* lines here are ignored by SAS. If at the end of your SAS code chunk they must be followed by a semi-colon. */ ;
You can use the usual Markdown within the text sections.
The entire document might be:
*+ setup, message=FALSE ; *R library(SASmarkdown) ; ** The report begins here.; *+ example1, engine='sas', comment=NA; proc means data=sashelp.class /*(keep = age)*/; run;
Set up an example file to use:
indoc <- " *+ setup, message=FALSE ; *R library(SASmarkdown) ; ** The report begins here.; *+ example1, engine='sas', comment=NA; proc means data=sashelp.class /*(keep = age)*/; run; " writeLines(indoc, "indoc.sas")
To process this document then, simply use
library(SASmarkdown) spinsas("indoc.sas")
Which gives a document, \"indoc.html\" that looks like
unlink("indoc.sas") unlink("indoc.md") unlink("indoc.html") detach(package:SASmarkdown)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.