Type: | Package |
Title: | 'SAS' Interface |
Version: | 0.1.5 |
Date: | 2025-03-30 |
Description: | Provides a 'SAS' interface, through 'SASPy'(https://sassoftware.github.io/saspy/) and 'reticulate'(https://rstudio.github.io/reticulate/). This package helps you create 'SAS' sessions, execute 'SAS' code in remote 'SAS' servers, retrieve execution results and log, and exchange datasets between 'SAS' and 'R'. It also helps you to install 'SASPy' and create a configuration file for the connection. Please review the 'SASPy' license file as instructed so that you comply with its separate and independent license. |
License: | Apache License 2.0 |
URL: | https://github.com/insightsengineering/sasr/, https://insightsengineering.github.io/sasr/latest-tag/ |
BugReports: | https://github.com/insightsengineering/sasr/issues |
Depends: | R (≥ 3.6) |
Imports: | checkmate, lifecycle, reticulate |
Suggests: | knitr, mockery, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-03-31 05:04:02 UTC; root |
Author: | Liming Li [aut, cre], Daniel Sabanes Bove [aut], Isaac Gravestock [aut], F. Hoffmann-La Roche AG [cph, fnd], AstraZeneca plc [cph, fnd] |
Maintainer: | Liming Li <liming.li1@astrazeneca.com> |
Repository: | CRAN |
Date/Publication: | 2025-03-31 18:50:02 UTC |
sasr
Package
Description
sasr
provides interface to SAS through saspy
and reticulate
in R.
Author(s)
Maintainer: Liming Li liming.li1@astrazeneca.com
Authors:
Daniel Sabanes Bove daniel.sabanesbove@gmail.com
Isaac Gravestock isaac.gravestock@roche.com
Other contributors:
F. Hoffmann-La Roche AG [copyright holder, funder]
AstraZeneca plc [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/insightsengineering/sasr/issues
onLoad Function
Description
onLoad Function
Usage
.onLoad(libname, pkgname)
sasr Environment
Description
sasr Environment
Usage
.sasr_env
Format
An object of class environment
of length 0.
Transfer data.frame to SAS
Description
Transfer
data.frame
object from R environment to SAS.
Usage
df2sd(df, table = "_df", libref = "", ..., sas_session = get_sas_session())
Arguments
df |
( |
table |
( |
libref |
( |
... |
additional arguments for |
sas_session |
( |
Value
"saspy.sasdata.SASdata" object.
Obtain the SAS Configuration File
Description
Obtain the file path of the SAS configuration file.
Usage
get_sas_cfg()
Details
Obtain the default sas configuration file. By default, it will search
the sascfg_personal.py
file under current directory. If it does not exist, it will
search this file under home directory. If this file does not exist, NULL will be returned.
Value
The file path of default SAS configuration file, or NULL if not found.
Get the Last or Default SAS Session
Description
Obtain the last session or default session.
Usage
get_sas_session()
Details
this function is designed to facilitate the R users programming practice of function oriented programming instead of object oriented programmings.
Value
A new SAS session if there are no previous SAS session, or the last SAS session created.
Install saspy
Module
Description
Install
saspy
module in reticulate
.
Usage
install_saspy(method = "auto", conda = "auto")
Arguments
method |
( |
conda |
( |
Value
No return value.
Run SAS code with SAS Session
Description
Run SAS code with a SAS session.
Usage
run_sas(sas_code, results = c("TEXT", "HTML"), sas_session = get_sas_session())
Arguments
sas_code |
( |
results |
( |
sas_session |
( |
Details
run_sas
will run sas code through SAS session.
The results is a named list of LST
and LOG
.
The result part will be stored in LST
, and log will be stored in LOG
.
If results
argument is "TEXT", then results are in text format;
if results
argument is "HTML", then results are in html format.
Value
Named list with following elements:
-
LOG
:string
of SAS execution log. -
LST
:string
of SAS execution result, in html or txt format.
SAS engine function
Description
SAS engine function
Usage
sas_engine(options)
Arguments
options |
See knitr documentation on engines. |
Create SAS Session Based on Configuration File
Description
Usage
sas_session(sascfg = get_sas_cfg(), ...)
Arguments
sascfg |
( |
... |
additional arguments passed to |
Value
SAS session.
Create SAS Session Based on Configuration File
Description
Usage
sas_session_ssh(sascfg = get_sas_cfg(), ...)
Arguments
sascfg |
( |
... |
additional arguments passed to |
Value
SAS session.
Create SAS Session Configuration File
Description
Create SAS session configuration file based on argument.
Usage
sascfg(
name = "default",
host,
saspath,
ssh = system("which ssh", intern = TRUE),
encoding = "latin1",
options = list("-fullstimer"),
...,
sascfg = "sascfg_personal.py"
)
Arguments
name |
( |
host |
( |
saspath |
( |
ssh |
( |
encoding |
( |
options |
( |
... |
additional arguments. |
sascfg |
( |
Details
host
and saspath
are required to connect to remote SAS server. Other arguments can follow default.
If transferring datasets is needed and the client(running sasr) is not reachable from the server,
then tunnelling is required.
Use tunnel =
, rtunnel =
to specify tunnels and reverse tunnels.
The values should be length 1 integer.
Value
No return value.
saspy package
Description
saspy package
Usage
saspy
Format
An object of class python.builtin.module
(inherits from python.builtin.object
) of length 0.
Transfer SAS Data to R
Description
Transfer the table in SAS session to R.
Usage
sd2df(table, libref = "", ..., sas_session = get_sas_session())
Arguments
table |
( |
libref |
( |
... |
additional arguments for |
sas_session |
( |
Value
data.frame
object.
Validate and Process data.frame
for SAS
Description
Validate if data contains validate variable names in SAS, and
remove possible row names.
Usage
validate_data(data)
Arguments
data |
( |
Details
In SAS, the variable names should be consist of letters, numbers and underscore. Other characters are not allowed. In addition, in SAS, row names(index) are not allowed.
Value
data.frame
Validate SAS Configuration File Exist
Description
Validate if SAS configuration file exist.
Usage
validate_sascfg(sascfg)
Arguments
sascfg |
( |
Details
Currently, only the file existence check is conducted and the rest is checked at python side.