The SASmarkdown package

SASmarkdown is an R package which, as you may be able to guess from the name, allows you to include SAS chunks in your RMarkdown (or Quarto!) documents.

Important

There is no interoperability between SAS and R through the SASmarkdown package. SAS datasets that you define in one chunk won’t be accessible in your R chunks, and vice versa.

With SASmarkdown, you can create RMarkdown (and Quarto) documents that look a little something like this:

How to use SASmarkdown

Install SASmarkdown in the usual way:

install.packages("SASmarkdown")

Once SASmarkdown is installed, it’s fairly easy to switch between the languages. All you need to do is specify which language you want to use in each individual code chunk.

To use SAS, set the engine option to sashtml and set the engine.path option to the file path of your SAS executable.

```{r, engine="sashtml", engine.path="C:/Program Files/SASHome/SASFoundation/9.4/sas.exe"}
proc means data=sashelp.class;
run;
```

To use R, leave the chunk header as the default.

```{r}
plot(cars)
```

And to use python, use the chunk header python.

```{python} 
print("Hello world!"[0:5])
```