Analyzer for SAS
Static analysis for SAS programs and their macros, across a whole project,
without running any code. It adds go-to-definition, find-references, hover
and diagnostics to the SAS support you already have.
SAS and all other SAS Institute Inc. product or service names are registered
trademarks or trademarks of SAS Institute Inc. This project is not affiliated
with or endorsed by SAS Institute Inc.
It works beside the official SAS extension
Install the official
SAS extension (SAS.sas-lsp)
first. It owns the SAS language in VS Code: highlighting, completion,
snippets, and running code. This extension contributes no language, no
grammar and no highlighting of its own, so without the official extension a
.sas file opens as plain text and nothing here starts.
What this extension adds is what a reader of the code can answer without a
SAS session:
- Go to definition and find references for macros, across files: a
%macro defined in another file is found when the caller can reach it,
through an %include that runs before the call or through an autocall
folder you configure.
- Data sets, too. Hover, go to definition and find references work on a
data set name in a DATA step, in PROC SQL, in a procedure's
data=,
out= and base=, and inside a macro body for the values each call
passes. Hover says which library the name is in, what this step does to
the table, and where it was last written.
- Hover says what a macro is, where it was defined and how this file
reaches it, and what kind of code it generates. On a DATA step variable it says
the variable's type and where its value came from.
- Diagnostics without running SAS: unclosed
%do, do and select
blocks, statements where SAS rejects them, a macro that generates a whole
step where only a value fits, an %include that cannot be found, macros
that no reachable file defines, and a few checks on DATA step variables.
Each code's severity can be changed, or the code turned off; parse
errors are the only findings no setting grades.
- Code lenses: "N references" above every
%macro, and on an included
file, which file includes it and how it is read there.
- Outline, folding and selection ranges for SAS files.
Macros are read, not run. A macro whose arguments are known at the call is
followed through for that call: its %if decided where those arguments
decide it, and its %do loops unrolled where their bounds are known.
Values that only the SAS session knows, such as a macro variable an
autoexec sets or a library a job assigns, can be supplied in the settings.
Settings worth knowing
All settings are under sas-analyzer. in the Settings editor. The ones that
make the biggest difference on a real project:
autocall.roots: the folders your SAS session searches for autocall
macros.
include.searchPaths, include.filerefs and include.rewrites: where
%include paths are found, including a deployment path that differs from
your checkout.
macroVariables: macro variables the session sets before your programs
run.
data.librefs: what a library name points to, where the program does not
say.
run.order: the order your programs run in, so a table one program
writes is found when the next one reads it.
lints: the severity of each diagnostic code, or off.
Windows (x64), macOS (Apple silicon and Intel) and Linux (x64 and arm64).
VS Code installs the package built for your platform.
Privacy
Nothing is executed: no SAS code and no other program from your project.
Everything happens on your machine, offline. The extension sends nothing
anywhere.