Welcome to the SAS Extension for Visual Studio Code! This extension provides support for the SAS language, including the following features:
- SAS Extension for Visual Studio Code
- Installation
- Features
- Support
- Contributing to the SAS Extension
- License
To install the SAS extension, open the Extensions view by clicking the Extensions icon in the Activity Bar on the left side of the Visual Studio Code window. Search for the 'Official' SAS extension, and click the Install button. Once the installation is complete, the Install button changes to the Manage button.
The SAS extension highlights these syntax elements in your program, just as they would appear in a SAS editor:
- Global statements
- SAS procedures
- SAS procedure statements
- Data step definition
- Data step statements
- SAS data sets
- Macro definition
- Macro statements
- Functions
- CALL routines
- Formats and informats
- Macro variables
- SAS colors
- Style elements and style attributes
- Comment
- Various constants
- Options, enumerated option values, sub-options and sub-option values for various procedure definitions and statements
You can choose among three SAS-related color themes that control the color of the application and syntax elements. The SAS Light, SAS Dark and SAS High Contrast options mirror the themes available in SAS Studio.
To specify the color theme:
- Select
File > Preferences > Color Theme
and select the theme, by name. The image below demonstrates the process changing from SAS Light to SAS Dark.
The SAS extension includes automatic code completion and pop-up syntax help for SAS keywords. The autocomplete, or code completion, feature in the code editor can predict the next word that you want to enter in your SAS program. See code completion in action below.
To use the autocomplete feature:
- Start typing a valid SAS keyboard. Scroll through the pop-up list of suggested keywords by using your mouse or the up and down arrow keys.
The syntax help gets you started with a hint about the syntax or a brief description of the keyword. You can get additional help by clicking the links in the syntax help window.
To view the syntax help:
- Move the mouse pointer over a valid SAS keyword in the code.
In the following example, the help panel displays syntax help for the DATA= option in the PROC PRINT statement.
Tip: Click the links in the syntax help window to navigate to the SAS online help.
Snippets are lines of commonly used code or text that you can insert into your program. The SAS extension includes snippets for SAS functions and procedures to facilitate writing your SAS programs.
To access the list of snippets for a function or procedure:
- Type the name of a function or procedure in your SAS program. This example shows a snippet for the PROC DS2.
Regions of code are identified in your SAS program as blocks of code that can be collapsed and expanded. You can also view an outline of your program that identifies DATA steps, procedures, macro sections, and user-defined regions of code.
Tip: You can define a custom region by adding /*region*/
and /*endregion*/
tags to the start and end of the block of code.
Before running SAS code, you must configure the SAS extension to access a SAS 9.4 (remote or local) or Viya server. You must license SAS 9.4 or Viya to run SAS code.
-
When first configuring, open up a file with the SAS language. "No Profile" can be located on the Status Bar located at the bottom left of your VSCode window
-
Either select the "No Profile" Status Bar Item or open the command palette (
F1
, orCtrl+Shift+P
on Windows or Linux, orShift+CMD+P
on OSX) and locateSAS: Add New Connection Profile
-
Please refer to the Add SAS Connection Profile section below to add a profile
-
After a profile is created, the Status Bar Item will be changed from "No Profile" to the name of the new profile.
-
If you do not want to generate results in HTML format, clear the
Enable/disable ODS HTML5 output
setting. This option is enabled by default.
Profiles are easy ways to switch between multiple SAS deployments. For Viya connections, multiple Viya profiles can be used to switch between compute contexts. There is no limit to the amount of profiles that can be stored.
Profiles will be stored into the VSCode settings.json file, and can be modified by hand, if needed.
The following commands are supported for profiles:
Command | Title |
---|---|
SAS.addProfile |
SAS: Add New Connection Profile |
SAS.switchProfile |
SAS: Switch Current Connection profile |
SAS.updateProfile |
SAS: Update Connection profile |
SAS.deleteProfile |
SAS: Delete Connection profile |
Details on creating and managing profiles is available on the Connect and Run page.
After configuring the SAS extension for your SAS environment, run your SAS program and view the log and results.
Details on running code is available on the Connect and Run page.
After configuring the SAS extension for a SAS Viya environment, you will be able to access SAS Content.
To access SAS Content:
- Click the SAS icon in VSCode's activity bar.
- Click Sign In.
- Your SAS Content should be displayed after sign in. From here, you are able to create, edit, delete, and run files stored on a SAS server.
Notes:
- SAS Content requires a profile with a connection to a Viya instance.
After configuring the SAS extension for a SAS Viya environment, you will be able to access your connected libraries.
You can use the libraries pane to delete a table, drag and drop tables into your SAS program code, or view a sample of the table data.
Notebook is an interactive experience with Markdown, executable code snippets and corresponding rich outputs organized in cells.
- To create a SAS notebook, select
SAS Notebook
from theNew File...
menu. - To change a code language, click the
Select Cell Language Mode
button at the bottom end of a code cell. - To toggle log or ODS output display, click
...
at the side of the output and selectChange Presentation
. - SAS Notebook can be saved to a
.sasnb
file, shared to others, and open in another VS Code window.
Ask, Find, and Share on the VS Code SAS Extension on the SAS Programmers Community site.
Please check the FAQ page for some common questions.
See the SUPPORT.md file for information on how to open an issue against this repository.
We welcome your contributions! Please read CONTRIBUTING.md for details on how to submit contributions to this project.
This project is subject to the Apache License Version 2.0, a copy of which is included as LICENSE