The SASjs VS Code extension is only available on Open VSX: https://open-vsx.org/extension/sasjs/sasjs-for-vscode
If you have questions or would like support, visit https://matrix.to/#/#sasjs:4gl.io.
- Code Documentation
- Code Execution
- SAS Log Errors and Warnings
- Directory Synchronisation
- SAS Lint and Format
- Language Server
- Compile, Build and Deploy
- Snippets for Base & SASjs Core
The extension runs the SAS language server shipped by @sasjs/sas-language, which compiles the language server of the official SAS extension for Visual Studio Code (SAS Institute's open-source extension, at a pinned upstream commit) and publishes it as an installable package. The extension stages the server into out/server/ at build time and spawns it over IPC on activation. It adds hover documentation, completions, document symbols, signature help, folding ranges, semantic tokens and formatting for SAS documents.
The SASjs lint stays the source of diagnostics: the server reports none (SAS errors surface from the log of a run). Both this extension's formatter (@sasjs/lint, which honours .sasjslint) and the server's formatting are registered; VS Code's default-formatter pick decides between them.
Generate HTML docs from your SAS code! Requires a local installation of Doxygen. Video overview available here.
Configuration is identical to the SASjs CLI, documented at https://cli.sasjs.io/doc, driven by the docConfig object.
Given that projects may be new to SASjs (without a sasjs/sasjsconfig.json file) the following workflow takes place:
- If workspace contains a
sasjs/sasjsconfig.jsonfile, go to Step 3 - If any parent directories contain a
sasjs/sasjsconfig.jsonfile, use this target, and go to Step 4. - Create a workspace-level
sasjs/sasjsconfig.jsonfile (and doxy files), and use this as the target. - Generate docs using target
docConfig.outDirectoryproperty (sasjsbuild/docsby default) - Put
index.htmlin focus
To view the index.html as a web page, open in Firefox, or right click and view with the Live Server extension (if installed).
You can run code on SAS Viya, SAS 9 EBI or SASjs Server! Just set up the target, and click the running man to execute your SAS code.
You can also highlight a section of code and run that. Each log returned will be stored in a sasjsresults folder. You can also run the SASjs: Execute Code command from the command palette(Cmd+Shift+P).
The target π― describes the server on which you intend to run the code. The attributes are added to a file in your home directory - ~/.sasjsrc. More info here).
The following attributes are needed for all server types:
- Name. An alias to represent the target.
- Server Url. The full URL (including port if needed) of your SAS server.
- Server Type. Can be SASVIYA, SAS9 or SASJS.
Below are the setup steps specific to each server type
Enter the following prompts:
- CLIENT / SECRET. Relevant for SASVIYA - you will need to ask your administrator for these, and they should have the
authorization_codegrant type. More info here. - Follow the link to obtain your authorisation code
For a SAS9 server type, you need to provide your user and passsword in the prompts. Before you can execute code, you will need a runner (an STP in your metadata home directory) - just follow the instructions here: https://cli.sasjs.io/auth/#sasjs-runner
vscodesas9.mp4
If you are using self-signed certificates and are unable to connect due to Error while handling error. Unable to verify the first certificate - but you ARE able to connect using the sasjs cli - then you may need to make the following adjustments:
- Set
"http.proxySupport": "fallback"in VS Code settings (instead of the default"override") - Set
"rejectUnauthorized": falsein the httpsAgentOptions object in the sasjsconfig file (sasjs/sasjsconfig.jsonor~/.sasjsrc)
In order to run on Foundation / Base / Desktop SAS you will need a running version of SASjs server (on the same machine where SAS is installed). You can download SASjs server here. Configuration instructions are here.
For local desktop instances of SASjs Server, the serverUrl is likely to be http://localhost:5000
If you are running SASjs Server in server mode, then you will need a client id - the default is clientID1
A SAS log is mostly notes; the lines that matter are the ERROR: and WARNING: ones. Open a SAS log and the extension marks them:
- the error and warning lines are coloured in the log, and the arrows in the editor title bar step between them from the cursor, wrapping at the end;
- they are listed in VIEW->PROBLEMS (ctrl+shift+M) next to lint issues, so F8 and Shift+F8 walk them and a click jumps to the line;
- notable notes are listed there as information - an uninitialized variable, invalid data, a format too small for its value, a silent type conversion, repeated BY values in a merge - but not coloured, so the errors stay on top;
- a message SAS wrapped over several lines is one problem, not one per line.
A marker counts when it begins the line, in capitals: ERROR: or WARNING:, or the marker and a space (ERROR Libref X is not assigned.), with SAS's message code travelling alongside where there is one (ERROR 22-322:). Ordinary notes ("19 observations read from the data set") and INFO lines are not listed.
The notable notes can be turned off - the eye button in the editor title bar, or sasjs-for-vscode.logNotableNotes in the project's settings (.vscode/settings.json), which is what the button writes. With them off, VIEW->PROBLEMS and F8 carry errors and warnings only. The log itself is untouched either way.
Which notes count as notable comes from SASLogChecker, Yutaka Morioka's MIT-licensed log checker: the 25 targeted NOTE / INFO examples in its help header map onto the keyword patterns here, and its matcher greps the same messages in Japanese, hex-encoded, because it reads logs from a Japanese Windows SAS session. Our patterns are the English text, so a Japanese log yields no notable notes. The list lives in @sasjs/utils (NOTE_KEYWORDS), so this extension, the SASjs Server Studio pane and any other host report the same findings.
A .log written by something other than SAS is left alone. Python's logging writes ERROR:root:boom and a shell build log writes ERROR: Command failed with exit code 1, so the marker alone proves nothing - the extension looks for what SAS prints about itself: its banner, its message codes and its numbered steps.
Sometimes when working with SAS, you would like to supply some physical content (eg macros, format definitions, Excel, images, etc) to the remote SAS server.
The syncDirectories feature lets you map one or more LOCAL (on your laptop) directories with one or more REMOTE (on the SAS server) directories.
It works by hashing the remote files, comparing the hashes with the local files, and deploying only the changed files. No SSH access needed, all files are deployed using 100% SAS Code.
More information is in the cli docs and this explanatory video.
To configure, just add the syncDirectories object to your local sasjs/sasjsconfig.json file. If this file does not exist, just click the Documentation icon to create one.
Spend less time on code reviews and more time pushing code! Select VIEW->PROBLEMS (or ctrl+shift+M) to examine the currently opened SAS program for issues.
Rules can be configured by creating a .sasjslint file in the root of your project as follows:
{
"defaultHeader": "/**{lineEnding} some custom header{lineEnding}**/",
"noEncodedPasswords": true,
"hasDoxygenHeader": true,
"hasMacroNameInMend": true,
"hasMacroParentheses": true,
"ignoreList": [
"sasjsbuild/",
"sasjsresults/"
],
"indentationMultiple": 2,
"lowerCaseFileNames": true,
"maxLineLength": 80,
"noNestedMacros": true,
"noSpacesInFileNames": true,
"noTabs": true,
"noTrailingSpaces": true
}Settings in the project (workspace) root (.sasjslint) take the highest precedence, followed by:
- User Home directory (
~/.sasjslint) - VS Code (extension) settings (
sasjs-for-vscode.lintConfig) - used only when neither.sasjslintfile can be read - Default settings (see https://github.com/sasjs/lint#sas-lint-settings)
Two buttons rewrite a SAS file, because they are two different jobs. Fix Lint Issues (the wand) applies the fixes a rule can make on its own - among them trailing spaces, line endings, the Doxygen header, the macro name in %mend, and the macro declarations a header lists but the file never invokes, which are removed from the header. Format (the alignment icon) lays the program out first - statement breaks, indentation and the boundaries between macro calls - and then runs those same fixes over the layout. A finding a rule cannot fix on its own, such as a tab used for indentation or a line over the length limit, is reported and left to you by both.
Both sit in the editor title bar and in the command palette ('SASjs: Fix Lint Issues' and 'SASjs: Format'). Both read their rules from the workspace's .sasjslint, falling back to ~/.sasjslint and then the extension setting, as described above.

Formatting can also be applied automatically to files on save/paste, from the Settings menu.

If a *.sas file is selected and a Compile, Build, Deploy icon is clicked, then a single file will be compiled, built and deployed. Compiled and built files will be located in sasjsbuild folder at the root of the project. If an error appeared during the process, log file should be created in sasjsresults folder.

if a sasjsconfig.json file is selected and a Compile, Build, Deploy icon is clicked, then an entire project will be compiled, built and deployed. Compiled and built files will be located in sasjsbuild folder at the root of the project. If an error appeared during the process, log file should be created in sasjsresults folder.

Snippets (code-completion) are provided both for Base SAS (using the official SAS VS Code Extension files) and SASjs Core (using the snippets generator of the SASjs CLI). To use snippets, just start typing SAS macro name, eg:
NOTE: If you don't see a snippet description, you might need to click the Read More icon, and snippet description will appear for all snippets, eg:
SASjs is an open source project, and contributions are warmly welcomed!
Bootstrap steps, the code layout, the two test harnesses, what CI enforces and how releases are cut are in CONTRIBUTING.md.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!



