Editor’s note: SASjs, while free and useful for anyone, is a gateway to services from 4GL Apps, a company founded and operated by longtime SAS user Allan Bowe.
I would like to start this post with a well-known quote by George Bernard Shaw: “If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.”
SAS Software provides vast functionality delivered with it, but perhaps the biggest asset of the SAS ecosystem is its ever-growing community of SAS users around the globe readily willing to share their SAS code and solutions to various problems. Take for example, SAS Communities, SAS blog or SAS Software on GitHub.
With open-source code taking the world by storm, SAS maintains and nurtures a viable mix of its rock-solid backbone – commercial SAS Software backed by its unparalleled Technical Support and open-source SAS solutions developed and shared by SAS users.
An introduction to SASjs
Here, I am going to introduce you to one more publicly available open source treasure called SASjs (also available on GitHub), which stands out from many others because of its thought-provoking, multifaceted approach.
In a nutshell, the SASjs is a collection of tools aimed at enabling and accelerating development and operations (DevOps) for a broad range of SAS applications, including SAS web development.
SASjs consists of the following three major components:
- SAS macro library (MacroCore)
- Command line interface (CLI)
SASjs MacroCore library
The MacroCore library is a centerpiece of the SASjs framework. It includes several hundred SAS macros facilitating various aspects of SAS coding, application development and deployments. All these macros are production quality and free to use (MIT-licensed). The contents of the MacroCore library organized by the following sections:
- BASE library (SAS9/Viya) - prefixes: mf (macro functions), mp (macro procedures - macros).
- FCMP library (SAS9/Viya) - prefix: mcf; used to generate user-defined functions using PROC FCMP.
- META library (SAS9 only) - prefix: mm; used in SAS EBI environments that connect to the metadata server.
- SERVER library (@sasjs/server only) - prefix: ms; used for building applications using @sasjs/server - an open source REST API for Desktop SAS.
- VIYA library (Viya only) - prefixes: mv, mvf; used for interfacing with SAS Viya.
- METAX library (SAS9 only) - prefixes: mmw, mmu, mmx.
- DDL Library - prefix: mddl; provides the structure for any permanent table used by the macros.
- LUA library - prefix: ml
All these macros (except METAX) are Operating System independent and operate under NOXCMD option. That option prevents the SAS program from executing OS commands and is often implemented by SAS Administrators for security reasons.
DOCUMENTATION PAGE – here you can find detailed descriptions for all of the SASjs MacroCore macros.
DOWNLOAD PAGE – here you can grab all these macros FREE and deploy (save) anywhere in your SAS environment.
Alternatively, you can make all these macros available in your SAS program by %INCLUDE-ing them directly from the Web – just add this code snippet to the beginning of your SAS program:
filename mcore url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; %inc mcore;
To give you a taste of what these macros are here is a small sample of them with examples of usage and brief descriptions:
- %mp_copyfolder(&rootdir,©dir) - copies the whole directory structure including files and subdirectories from one location (&rootdir) to another (©dir). Uses only internal SAS functions without OS commands (NOXCMD option).
- %mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX) - returns SAS table myTable listing all files and sub-directories up to specified depth. It also uses only internal SAS functions without OS commands (NOXCMD option).
- %mp_csv2ds(inref=mycsv,outds=myds,baseds=template_ds) - imports relevant columns from mycsv CSV file to myds data table using a template dataset template_ds to provide the types and lengths.
- %mf_getvarcount(my_dataset) - this macro function returns the number of variables in a dataset.
- %mf_getvarlist(sashelp.class,dlm=%str(,),quote=double) - this macro function returns the dataset variable list directly from its header. The list can be separated by blanks, commas or any other delimiter (dlm=), and be unquoted or quoted (quote=).
SASjs uses the following two client-side components:
- Visual Studio Code (VS Code) source code editor.
SASjs command line interface (CLI)
The SASjs CLI is the third major component of SASjs that ties together and facilitates creating, building, deploying and executing various SAS web applications (for SAS 9 and SAS Viya).
It is a powerful and flexible tool covering a wide range of features and functionalities to support successful applications development and operations (DevOps). CLI’s primary actions include:
- Create a template SASjs Git project repository.
- Compile dependent macros, macro variables and pre/post code.
- Create/build the master SAS deployment, including Jobs, Services and Tests.
- Deploy/execute local scripts and remote SAS programs to create your app on the SAS Server.
- Configure and generate Doxygen documentation for all SAS content.
There is also a feature to let you deploy your frontend as a service, bypassing the need to access the SAS Web Server.
Even though SASjs is an open source platform, it provides different levels of support for its products.
Report defects. Through this GitHub web page SAS users can raise issues with SASjs such as report defects, suggest improvements, etc.
Engage with SASjs developers. SAS users can also communicate with SASjs developers, receive free clarifications and consultations on various aspects of SASjs usage, or even hire them for involvement that is more extensive.
Questions? Thoughts? Comments?
Do you find this post useful? Have you learned anything new? Do you have any other SAS open-source assets you can share? Do you have questions, concerns, comments? Please share with us below.
SAS open-source treasures from around the world: SASjs was published on SAS Users.