SAS (Base SAS)+
*==============================================================================;
* SAS has no direct equivalent of library() because most procs are built in. ;
* The closest analogues are pointing SAS at external code that it cannot see ;
* until we attach it. ;
*==============================================================================;
*------------------------------------------------------------------------------;
* 1. Autocall macro library (similar to loading user-written code). ;
*------------------------------------------------------------------------------;
options mautosource sasautos = ("C:\my_macros", sasautos);
*------------------------------------------------------------------------------;
* 2. Format catalog (similar to attaching saved formats). ;
*------------------------------------------------------------------------------;
libname fmtlib "C:\my_formats";
options fmtsearch = (fmtlib work library);
* After these statements, macros in C:\my_macros and formats stored in fmtlib ;
* are available for the rest of the session. ;- SAS does not have a single one-line equivalent of R’s
library()call. - That is because most of what we use in clinical programming (DATA step, PROC MEANS, PROC SORT, PROC TRANSPOSE and so on) is already compiled into SAS and available by default.
- For user-written autocall macros, we point SAS at the folder with
options mautosource sasautos = (...). - This is the closest match to
library()— it extends the session so new function-like code becomes callable by plain name. - For user-defined formats, we use
libnameandoptions fmtsearch = (...)together to tell SAS where to look. - Nothing new gets copied into the program. SAS just becomes aware of the extra location, the same way R becomes aware of a package after
library(). - We put these statements near the top of the program, just like
library()calls sit at the top of an R script.