sasquatch
works by utilizing the SASPy
python package, similar to packages like sasr
or configSAS. This
means everything we do to connect R and SAS, needs to go through
SASPy
.
Setting up SASPy
can be difficult, but this guide is
here to help you! Keep in mind there are several different SAS
connection methods. The following vignette will go through setting up
SASPy
with SAS On Demand for Academics (ODA), but the
process is roughly generalizable.
For more information about setting up non-ODA SASPy
connections, check out the SASPy
configuration documentation.
Registration
SAS ODA is free SAS client for professors, students, and independent learners. Create an account at https://welcome.oda.sas.com/.
Once you have set up your account, log in and note the ODA server (in the picture below United States 2) and your username (under the email in the profile dropdown). We will need these for later.
Installation
Install the sasquatch
R package from GitHub:
# install.packages("pak")
pak::pkg_install("ryanzomorrodi/sasquatch")
Make sure Python is installed on your system. You can download from
Python Software
Foundation, or use install_python()
from
reticulate:
reticulate::install_python()
Use the install_saspy()
function to install
SASPy
. This will automatically create an isolated virtual
environment called “r-saspy”.
sasquatch::install_saspy(envname = "r-saspy")
Make sure Java is installed on your system. You can download Java from their website. Note the Java installation path.
Configuration
Set up for SAS ODA is super easy. Run config_saspy()
and
follow the prompts (you may need to recall your username, server, and
java installation path from earlier).
sasquatch::configure_saspy(template = "oda")
RStudio
Within RStudio, you should be able to run SAS chunks as you would any
other chunk. However, if you want to be able to view SAS output within
the Viewer instead of beneath the chunk, you can utilize the
sas_run_selected()
addin. To add a keyboard shortcut for
this addin, open Tools -> Modify Keyboard Shortcuts and search “Run
selected in SAS”, type in the box under Shortcut to set the keyboard
shortcut to your liking and click Apply.
Positron
Within Positron, you will not be able to run SAS chunks as you would
R or Python chunks. However, just as in RStudio, you can create a
keyboard shortcut which will allow you to view SAS output within the
Plots pane. Open up the command palette with ctrl+shift+p
or command+shift+p
and search “Preferences: Open Keyboard
Shortcuts (JSON)”. Add the following to your shortcuts.
{
"key": "ctrl+shift+enter",
"command": "workbench.action.executeCode.console",
"when": "editorTextFocus",
"args": {
"langId": "r",
"code": "sasquatch::sas_run_selected()",
"focus": true
}
}
Edit the key
argument to set your preferred
shortcut.