BookmarkSubscribeRSS Feed

SAS Extension for Visual Studio Code

Started ‎06-30-2022 by
Modified 4 weeks ago by
Views 62,157

TL;DR

SAS has officially released a VS Code SAS programming code extension. The extension is available on SAS’ Visual Studio Marketplace, and we’ve also created the sas-vscode-extension repository on sassoftware GitHub

 

As of June 2024, the most recent release of the SAS Extension for VS Code is v1.10. It supports connections to any modern SAS environment, including:

  • SAS Viya
  • SAS 9.4 Remote (using IOM, Windows only)
  • SAS 9.4 Remote (using SSH)
  • SAS 9.4 Local (on Windows, when VS Code is on Windows)

New in v1.10: revised documentation that is easier to navigate. See it here: https://sassoftware.github.io/vscode-sas-extension/.

 

Also see this video series from @DavidHD to get started. (Subscribe to the channel to get new updates!)

 

 

VS Code SAS Extension Introduction

In 2019 a survey on Stack Overflow listed VS Code as the IDE of choice for 50% of the developers surveyed. That number jumped to 74% in 2023. Moral of the story: VS Code is popular in the developer community and is still growing in adoption. Rather than asking developers to log into, and code in, the SAS UI, we’ve developed the VS Code SAS Extension. The tool offers users an integration point for adding SAS programs and code into their work, without having to switch applications. The tool also offers the ability to connect directly to SAS Viya and run code.

 

Repeat for those who skipped TL;DR: The extension is available on SAS’ Visual Studio Marketplace, and we’ve also created the sas-vscode-extension repository on sassoftware GitHub. The extension can connect to SAS Viya and SAS 9.4 to edit and run code, and can be used standalone as a powerful development tool for SAS programmers.

 

Features

The extension includes the following features and is continuous developed to add more. Some features are available only for certain connection methods -- see this matrix of capabilities for more information.

 

SAS Syntax Highlighting Color Themes Code Completion
Pop-up Syntax Help Snippets Code Folding and Code Outline
Configuring the SAS Extension Running SAS Code VS Code for the web compatible
VS Code Notebooks Data Viewer Libraries and Data set navigation

 

The list above is not exhaustive and we're just at the beginning. We plan on adding more features over time. I will not go through the specific features in this article. Rather, I’ll offer some background on why SAS created the tool, how it can benefit users, run through a short use case, and challenge you to be creative in using the extension.

 

Who are we trying to reach?

The extension is open for use by anyone using VS Code; however, there is certainly a user base that would be more apt to adopt it. We’re a data-driven company. Numbers don’t lie. Based on the Stack Overflow survey results, it’s clear developers do their work in VS Code. We need to meet these users where they are. Consider the scenario below and see how the extension benefits developers.

 

The developer using VS Code

If during the day you write Python, then some JavaScript, and then some SAS, and VS Code is your favorite place to be… now you can write your SAS code there too. Our goal is to meet your SAS programming needs by supporting the number one code editor in the industry today. Our new VS Code extension for SAS is lightweight, runs anywhere, and allows you to integrate SAS and other languages.

 

Let’s also consider other potential users.

 

The SAS Studio user

We’re not suggesting SAS programmers alter what they do in SAS Studio, in any way. The VS Code extension offers an alternative, if the need arises, to be flexible with a new integration point.

 

What about other users?

Additionally, students, companies that support the use of VS Code in their tech stack, and Microsoft’s Azure DevOps customer base will have the opportunity to make use of the SAS extension.

 

Project development and support

While the initial contribution of core functionality is by SAS R&D, we expect and encourage continued contributions by SAS developers, partners, and consultants. In fact, we’ve already seen issues logged and conversations occur in the Marketplace and on GitHub.

 

SAS has a commitment to support the community contribution effort through code reviews and assistance with critical bugs. We also expect this to be a popular topic in the SAS Support Community. A conversation on this subject in the Developers Community has over 6k views and comments from several users wanting to contribute.

 

Install, configure, and feature use

 

Video format

In the following video, I cover extension installation, configuration, and highlight multiple features.

 

 

 

Text format

Let's take a look at installation and functionality using this simple use case.

  1. install the extension
  2. add SAS Code to a programming window in VS Code
  3. configure connection to SAS Viya instance
  4. run the code and verify the results

 

Install the extension

Two ways to accomplish this:

  1. Go to the SAS page on Visual Studio Marketplace and click Install.
    • This should open VS Code and install the extension for you.
  2. Open VS Code, navigate to Extensions and enter SAS in the filter.
    • Make sure to find/install the extension with the description Official SAS Language Extension for VS Code.

 

Configure the SAS theme

This setting enables things like SAS programming color coding, type ahead, the 'SAS running man' icon, and other SAS-specific features.

  1. Navigate to File-> Preferences, Color Theme
  2. Choose one of three SAS themes: SAS Light, SAS Dark, or SAS High Contrast

 

Enter SAS code

  1. Open a new programming window by selecting File-> New Text File, click Select a language, and choose SAS from the list.
  2. Enter SAS code (you can use the following test code or use your own).
data race;
    pr =probnorm(-15/sqrt(325));
run;
proc print data=race;
    var pr;
run;

 

Establish connection

For more information about the authentication process, please see the blog post Authentication to SAS Viya: a couple of approaches.

 

You can create a Profile with connection information to SAS Viya. You have the ability to create multiple profiles to connect to different SAS Viya environments. Profile configuration depends on your SAS Viya version. 

 

Connecting to SAS Viya, release 2022.11 and later

Connections to SAS Viya use an authorization code and the pre-loaded vscode client id.

  1. Press F1 to kick off the 'SAS: Add New Connection Profile' wizard
  2. Enter a profile name
  3. Select the SAS Viya option for Connection Type.
  4. Provide the SAS Viya url, e.g., https://sasserver.sas.com
  5. Accept the SAS Job Execution compute context (default)
  6. When prompted to enter client id, PRESS Enter, do not provide a client id.

 

Connecting to SAS Viya, prior to release 2022.11 (including Viya 3.5)

Connections to SAS Viya use an authorization code and a client id created by a SAS Admin

  1. Press F1 to kick off the 'SAS: Add New Connection Profile' wizard
  2. Enter a profile name
  3. Provide the SAS Viya url, e.g., https://sasserver.sas.com
  4. When prompted to enter client id, enter a valid client id (see documentation for client registration steps)
  5. Enter a client secret

 

More information on profile creation is in the preceding blog post link and on GitHub. If you hit connection issues, refer to the FAQ on GitHub.

 

Run code

The extension uses the current profile to connect to SAS Viya. On the initial connection to SAS in a VS Code session follow these steps:

  1. Click on the SAS running man in the upper-right-hand corner of the code window.
  2. A SAS login screen appears
  3. Log in using your SAS credentials
  4. If prompted, authorize access for all scopes
  5. Copy the generated authorization code
  6. Paste the authorization code in VS Code
  7. Results should be displayed in the Results tab.

See the Running SAS Code section of the README for more details.

 

Note: subsequent calls in the same VS Code session will connect directly to SAS Viya. You do not need to repeat the authorization code steps.

 

Use cases needed

Want to become a star? Ready to impress everyone? Here’s where you can help. You'll hear plenty from SAS about the new VS Code extension; however, oftentimes our users come up with the best ideas for use of our software and tools. If you have a use case that’s more interesting than what’s outlined above (a simple code example, only using SAS), we’d love to hear about and feature it.

 

Finally

Is this project complete? Absolutely not. We're adding additional functionality and making improvements based on user feedback. We've also processed multiple pull requests on GitHub incorporating changes from the field. We want to continue providing proper functionality, responding to user concerns, and facilitating the use of our new extension. Try it out and tell us what you think.

Comments

This is Great! Any upcoming plans to support Web Job Execution Server code, parameters and associated HTML pages? Would really be useful to be able have true source code control over JES jobs and web pages.

Hi @eneidam,

Thanks for your inquiry. To my knowledge nothing is in the works, but I really like your idea. I'd suggest posting this as in Issue in the GitHub repository. That's the best place to log feature requests.

Thank you @joeFurbee  !  This is a great tool and the video demo is also very engaging in order to adopt it. I am not familiar with VsCode, this might change quite soon 😉 

I cannot connect at the moment with a Viya 4 installation, I would like to know wich API type and protocol does the extension use actually. I guess this is RESTful / http(s) but I need to be sure for a network route opening.  Behind the scenes, is this the Compute services being consumed or another one ? 

 

https://support.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2083-2018.pdf

 

I saw on the Github page a request for having SAS 9 (local Foundation AND/OR remote IOM) also as an endpoint to the extension. I would be very interested with this feature since this would enable a side by side exploitation { SAS 9 } |  { Viya } during migrations from SAS 9 to Viya, thus streamlining manual unit testing for instance. 

Hi @ronan,

Answers to your questions:

The  the extension is connecting with REST API over http(s) to the Viya compute service.

 

At this time the extension is for SAS Viya only. We are exploring the possibility of further feature development for SAS 9 compatibility. Stay tuned.

 

 

 

Thank you, @joeFurbee , that's clear.

Hi is the extension supported in RedHat  OS ? We are having troubles in installing it on VS Code running on Linux RedHat.

 

Thanks

Hi @mbertol4  - I suggest you post the question as a GitHub issue and the team can respond.

Submitted in GitHub as suggested.

Thanks

Hi, Great! Is there also a possibility to access the NFS (Network File System) in VS CODE as in SAS Studio? I have organized my Code and other files (excel files e.g.) in NFS folder (using "classic" statements like %include and classic access of excel or textfiles.  And I want to save and run .sas Files stored in NFS directly from VS Code. So not to use only the SAS (Metadata) Content.

 

@AThomalla When using VS Code to run SAS programs, the programs are run on your SAS environment. So whatever environment you connect with must have access to the files you reference with %include or filename statements. If all of your files are "local" to your desktop, but your SAS session is remote -- then each flle that you need must be uploaded to that remote environment before you can reference it.

@ChrisHemedinger 

Thanks for your reply. Yes, I can access my files running code on the server, but my question is, if I can access these files (open, edit, save as in SAS Studio) directly from VS Code (so organize my code files within VS CODE). My intention is also a bit: if some future AI Copilot Extensions (github copilot, openai) will be able to create code for you based on own nomenclatura of dataset filenames and attribute names AND your existing code/project, it will be probably usefull that VS CODE hast access to these files. And for me currently it is not a solution to move my code to SAS (Metadata) Content because then existing "classic" programms and methods are not working without migration (e.g. I use alread proc python and cool methods produced with help of chatGPT which use usual file system (excel, text, code files)).

@AThomalla I think I understand. I don't know what the future holds for tools like Copilot being able to help you craft code that is specific to your data files and their metadata. That's granting the tool a lot of access to your SAS-controlled data and may be problematic from a policy standpoint (it certainly would be a concern in our workplace).

 

But lots of people are like you in that they manage their SAS files in the file system, not in metadata or content server. VS Code is a client to SAS (like EG is or SAS Studio), and so can only do so much to manage your local files in concert with their meaning/semantics in your remote SAS environment.

@ChrisHemedinger thanks for the update. As VS CODE is a client like SAS STUDIO I just wonder, why access the NFS Files is not provided as within SAS Studio as well. As mentioined, existing SAS Applications which base on SAS Files managed in the file system are not directly compatible with sas files or files in general stored in metadata. Would be nice, if SAS would enable managing the NFS files in VS Code same as in SAS Studio...

 

Regarding the sucerity concern using extensions like copilot its clear... But in my view its the future for "smart" solution building. And one should be aware of it when planning future architectures and development methods within the dev teams.

 

Currently the quality of chat GPT output with Python is amazing in my opinion. Imaging one would combine the already exisiting features with (secure) access to own data: that will be funny :-).

Thanks!

@AThomalla My statement that VS Code is a client like SAS Studio is sort of misleading, since VS Code is installed locally and SAS Studio is on a remote server (on network with your NFS share) close to your SAS session. If where you're running VS Code and where you run SAS are sharing the same file system/network, then these references could work. However, that's often not the case.

Just started using this with my SAS 9.4 local PC Windows install, and first let me say, it looks awesome! I'm trying to get my whole dept to consider it as alternative to native PC 9.4 editor. I have two questions, though:

1) How do you get the LIBRARIES pane - as shown at 5:13 in the video. Is LIBRARIES pane only visible if you connect to SAS Viya? Is it visible for those of us using SAS 9.4 on our local Windows PC, with no SAS Viya server? I see the Libraries header, but when I expand it, it contains no library names, not even SASHELP.

2) Even though he is using SAS Dark theme, at 9:40 in the video, his SAS output shows with white background - similar to how it appears in SAS Enterprise Guide. But when I use SAS Dark theme, SAS output is also dark theme (dark background, etc.). How did he get output to appear with light background?

@bnawrocki Libraries/data set viewing is not yet supported for local connections but it is being worked on!

 

The output theme is tied to ODS styles. The extension will try to match an ODS style to your editor theme, but of course it's not 1-to-1 and you can override by adjusting your ODS HTML5 statement to include the style= value of your choice.

@ChrisHemedinger - thanks for the quick response.

After reading your comments, I looked at SAS Enterprise Guide HTML option (via Tools --> Options-->HTML) and saw it uses HTMLBlue style.

I was able to reproduce SAS EG's HTML style by adding this code to top of my SAS code in Visual Studio Code:

   ods html5 style=htmlblue;
 
As a side note: I first saw Visual Studio Code and its SAS extension at SESUG2023 in Charlotte in October, so yes, a regional SAS conference is worth attending!

Does a detailed setup video exist for SAS Studio 9.4 for Windows? Server and Client setup? The instruction at vscode-sas-extension/connect-and-run.md at cab241e4db321a3765f471508d9835362e2ebba9 · sassoftware/vs... are confusing of what is done on the server and what is a client config.

@joeFurbee  These are great but I don't see anything about setting up connecting vscode to SAS Studio 9.4. The documentation seems to fall a little short at https://github.com/sassoftware/vscode-sas-extension/blob/cab241e4db321a3765f471508d9835362e2ebba9/co... Does OpenSSH server need to be installed on the SAS server?

 

I am connected now, but I don't see my server with my saved code and datasets loading. They don't sit in the folders currently shown in the explorer.

 

Anybody know how to add these servers to the explorer?

 

What I see in visual studio:

illmatic_0-1708979292987.png

 

versus what I see in SAS studio on Viya:

illmatic_2-1708979350736.png

 

 

Hi, 

I think I managed to get everything installed correctly but when I hit the running man I see this in the log window:

JAVA_OPTIONS="-Djava.awt.headless=true" /net/sas94linuxM6/SASFoundation/9.4/bin/sas_u8 -nodms -terminal -nosyntaxcheck
 
along with the message: 
_JAVA_OPTIONS=-Djava.awt.headless=true: Command not found.
 
Looks like my client is successfully sending something to the server but the Java options is not being interpreted correctly. 
Am I missing something?
Thanks, 
     Rodger

@madrodger Which method of connection are you using? SSH? If possible you might find it easier to set up "Remote IOM", which can work using the same way that EG connects to a remote SAS session. But if you're not running VS Code on Windows and/or you don't have your Linux environment set up with SAS Integration Technologies, then that's a no-go.

HI Chris, 

I'm using SSH, running VS Code on Windows 10 and don't have SAS Integration Technologies set up on the server. My settings.json has this:

 "profiles": {
            "pandora": {
                "connectionType": "ssh",
                "host": "pandora.rand.org",
                "saspath": "/net/sas94linuxM6/SASFoundation/9.4/bin/sas_u8",
                "username": "rodger",
                "port": 22
            }
        }
 

@madrodger I suggest you create an issue for this at https://github.com/sassoftware/vscode-sas-extension/issues. The team is very responsive with ideas.

Hi @ChrisHemedinger ,

 

I posted this - Re: SAS 9.4 (TS1M7) VS Code extension set up - no running man icon sho... - SAS Support Communities

 

Any idea why it is not working my installation?  I don't even get the running man icon.

 

Thanks,

James

 

Can anyone please help?

 

For the life of me I cannot turn OFF auto indent in VS Code for SAS language/files.  I have tried every setting, and it still indents lines.

 

"editor.autoIndent": "none",

 

"[sas]": {
"editor.autoIndent": "none"

}

 

"workbench.settings.applyToAllProfiles": [
"editor.autoIndent"

]

 

Nonetheless, lines still always indent.  Please help!

I have VS Code and SAS Foundation 9.4 installed locally, including Integration Technologies. I think VS Code is a bit nicer than the classic SAS editor DMS setup. So I would like to use this extension in stead.

 

When setting up a connection to my local SAS using "localhost" I can run SAS code and see log and results, but not view the datasets for some reason. Apparently that is not possible (yet?) even though I would guess that would be one of the most popular use cases, at least here at our site where everyone has a local SAS installed.

 

That got me thinking, could I set up a connection using IOM to my local SAS install and would that then give me the ability to view datasets etc ? If so, could someone spell out how to set up that connection, since that is not covered by the standard examples.

 

Thanks!

@JB1_DK These capabilities - view libraries and datasets, and a data set viewer -- are in development and should be ready soon. This works today with SAS Viya -- it's coming soon for Local SAS and IOM hosts.

@ChrisHemedinger Thanks Chris, looking forward to that

@ChrisHemedinger @JB1_DK Thank you both - I was looking at the exact issue with my install.  I hope the updates will be available soon.

tjc

Hi, I'm using the SAS VS Code extension (1.7.2) with Visual Code (1.87.2) to connect to a remote Linux SAS server (SAS 9.4M6) using an IOM connection (phew!).

 

However, with HTML5 output unchecked, when I submit SAS code from a simple *.sas file, I can see log output (e.g., from PROC SETINIT) but no list output (e.g., from PROC PRINT or SQL) even though the log shows the procedures ran fine.

 

With HTML5 output checked, I see no log/list output when code is submitted from a *.sas file.

 

And if I submit simple code (proc setinit; run;) with HTML5 output enabled from a SAS Notebook, not only is there no output, but the following error message is displayed (saw something similar in another post, but no solution was identified in post):

_____
 
Error: There was an error executing the SAS Program. See [console log](command:workbench.action.toggleDevTools) for more details.
at Hx.onShellStdErr (c:\Users\myIDhere\.vscode\extensions\sas.sas-lsp-1.7.1\client\dist\node\extension.js:264:155)
at Socket.emit (node:events:514:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Socket.push (node:internal/streams/readable:234:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

_____

 

So, any thoughts on what might be missing and causing this error and preventing output and log to be retrieved successfully? 

 

Very neat extension, hope to get it running soon! 😀

 

Thanks! 

 

tc

 

Btw, below is what profile looks like as well as successful SAS Integration Technologies test dropdown settings:

_____

 

"sas9IOM": {
"username": "my ID here",
"host": "my.server.com",
"port": 8591,
"sasOptions": [],
"connectionType": "iom"
},

_____

 

SAS Integration Technologies Configuration Wizard drop down options:

 

SAS Workspace Server
IOM Bridge
Credentials
SASProprietary

@tjc I recommend that you post your issue to the GitHub Issues page for the VS Code extension project. The team is very responsive.

tc

Is it possible to specify an autoexec file for the SAS connection when running the extension against a Local SAS install ? Github only mentions Viya so it may not be supported yet for Local

 

Hi @JB1_DK,

I'd recommend asking your question by opening an Issue on the SAS VS Code GitHub page. The team is very active.

Hi @joeFurbee 

I am trying to connect VS Code to the SAS Viya at my organization (SAS Viya V.04.00 on AKS using Single sign-on). However, no matter what I try I always get the message "unable to verify the first certificate" once I insert the Authorization Code.

a_SAS_sin_0-1714479857849.png

For reference, I even managed to register a client app using the instructions you provided here (Authentication to SAS Viya: a couple of approaches - SAS Users) and it worked when I tested with the API but I cannot make it work with the VS Code.

 

Thank you 

 

 

Just FYI: With the update from today, data set viewer is now working for Local SAS

Hi @a_SAS_sin,

First thing to try is to log out/in in VS Code. If that does not work check out this solution in SAS VS Code GitHub FAQ page. If that doesn't work, best thing to do is create an issue on the GitHub page.

Hi @joeFurbee 

 

The "this solution" link you sent points to an ESPN page (someone is a fan of American football 😉). 

Could you please update that?

Thank you 

@a_SAS_sin Fixed that link. You should see @joeFurbee's open tabs in his browser -- would make your head spin.

Hi @a_SAS_sin. Sorry about that. The link was on my clipboard from my lunch browsing. Thanks @ChrisHemedinger for fixing.

Hi @joeFurbee,

Downloading and installing the certificate did not work but setting the environment variable did the job.

Thank you very much

hf_

I am trying to set up a connection from VSCode on Windows to our SAS 9 setup on Linux using SSH. I fail, but I am also wondering what remote server that the instructions points to. Is it the metadata server or the compute server?

When I connect using IOM it works, but then I have to point it to the compute server. It seems a bit strange! 🙂

The IOM connection is for the Workspace (compute) server -- bypasses the metadata server. The SAS extension is not metadata-aware (at this point, not sure if that's something we'll pursue).

 

If you can use IOM that will give you more features than SSH. See the matrix of connection capabilities here.

 

Version history
Last update:
4 weeks ago
Updated by:

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags