Skip to contents

The Slc class provides the main interface for connecting to and interacting with Altair SLC (Statistical Language Compiler). It manages the SLC process, handles communication via the ORB protocol, and provides high-level methods for submitting SAS code and managing data.

Details

This class handles:

  • Starting and managing the SLC process (wpslinks)

  • Establishing communication via named pipes

  • Creating and managing SLC sessions

  • Submitting SAS code for execution

  • Accessing logs, listings, and macro variables

  • Managing SAS libraries and datasets

The connection uses the ORB (Object Request Broker) protocol to communicate with SLC through named pipes (FIFOs on Unix/Linux systems).

Environment Requirements

The SLC binary must be available. The class looks for it in:

  1. $WPSHOME/bin/wpslinks (if WPSHOME environment variable is set)

  2. $WPSHOME/MacOS/wpslinks (on macOS)

  3. Default installation paths like /opt/altair/slc/*/bin

Set the WPSHOME environment variable if SLC is installed in a non-standard location: Sys.setenv(WPSHOME = "/path/to/slc/installation")

Methods


Method new()

Create new SLC connection

Usage

Slc$new(sys_options = list())

Arguments

sys_options

List of system options


Method find_slc_binary()

Find SLC binary directory

Usage

Slc$find_slc_binary()

Returns

Path to binary directory or NULL


Method get_binary_folder_name()

Get binary folder name based on OS

Usage

Slc$get_binary_folder_name()

Returns

Folder name string


Method get_binary_search_paths()

Get binary search paths

Usage

Slc$get_binary_search_paths()

Returns

Character vector of paths


Method get_binary_name()

Get binary name

Usage

Slc$get_binary_name()

Returns

Binary name string


Method submit()

Submit SAS code

Usage

Slc$submit(text)

Arguments

text

SAS code string

Returns

Integer return code


Method submit_file()

Submit SAS code from file

Usage

Slc$submit_file(filename)

Arguments

filename

Path to file

Returns

Integer return code


Method get_library()

Get library reference

Usage

Slc$get_library(name = "WORK")

Arguments

name

Library name (default "WORK")

Returns

Library object


Method create_library()

Create new library

Usage

Slc$create_library(name, path, engine = "WPD")

Arguments

name

Library name

path

Library path

engine

Engine name (default "WPD")

Returns

Library object


Method get_library_names()

Get library names

Usage

Slc$get_library_names()

Returns

Character vector of library names


Method get_macro_variable()

Get macro variable value

Usage

Slc$get_macro_variable(name)

Arguments

name

Variable name

Returns

String value


Method set_macro_variable()

Set macro variable

Usage

Slc$set_macro_variable(name, value)

Arguments

name

Variable name

value

Variable value


Method get_log()

Get log output

Usage

Slc$get_log()

Returns

String


Method get_listing_output()

Get listing output

Usage

Slc$get_listing_output()

Returns

String


Method clear_listing_output()

Clear listing output

Usage

Slc$clear_listing_output()


Method shutdown()

Shutdown SLC connection

Usage

Slc$shutdown()


Method clone()

The objects of this class are cloneable with this method.

Usage

Slc$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
# Basic connection and code submission
slc <- Slc$new()

# Submit SAS code
slc$submit('
  data test;
    x = 1;
    y = 2;
  run;
')

# Get the log
log_output <- slc$get_log()
cat(log_output)

# Get listing output (from PROC PRINT, etc.)
slc$submit('proc print data=test; run;')
listing <- slc$get_listing_output()

# Work with libraries and datasets
work_lib <- slc$get_library("WORK")
datasets <- work_lib$get_dataset_names()

# Convert between R and SAS data
work_lib$create_dataset_from_dataframe(mtcars, "cars")
cars_df <- work_lib$get_dataset_as_dataframe("cars")

# Macro variables
slc$submit('%let myvar = hello world;')
value <- slc$get_macro_variable("myvar")

# Clean shutdown
slc$shutdown()
} # }