How to install "Visual Studio Code" on your PC, add the "SAS Extension for Visual Studio Code", and add the "SAS® Viya® Copilot"


This SAS KB article explains how to install “Visual Studio Code” on your PC, add the “SAS Extension for Visual Studio Code”, and add “SAS Viya Copilot”.

This article also explains how to set up connections to a SAS Viya server, a SAS® 9.4 server, and a local PC installation.

Table of Contents


Documentation

For detailed information, see the SAS Extensions for Visual Studio Code documentation.


Download and Installation

Download and Install the “Visual Studio Code” App

See the following resource to access the downloads: https://code.visualstudio.com/download.

visual studio code app.png

Add “SAS Extension for Visual Studio”

Complete the following steps to add the SAS Extension for Visual Studio:

  1. Start Visual Studio Code.
  2. Click the Extensions button in the left panel.
  3. Search for SAS Extension.
  4. Install the Official SAS Language Extension.
  5. Click Install:

install visual studio code sas extension.png

The SAS icon is displayed in the left panel:

sas icon.png

Add “SAS Viya Copilot”

Note: SAS Viya Copilot works with only SAS® Viya® 2025.12 and later.

Complete the following steps to add the SAS Viya Copilot:

  1. Start Visual Studio Code.
  2. Click the Extensions button in the left panel.
  3. Search for SAS Viya Copilot.
  4. Click Install:
    install sas viya copilot.png

The SAS icon is displayed in the left panel:
sas icon 2.png

Add the Windows System Environment Variable to Connect to SAS Viya

Complete the following steps to add the Windows System environment variable to connect to SAS Viya:

For more information, see the Frequently Asked Questions section in the SAS Extension for Visual Studio Code documentation.

  1. Set the NODE_TLS_REJECT_UNAUTHORIZED environment variable to 0 to bypass the certificate check.
  2. Shut down all VS Code instances.
  3. Then, restart the application with the updated environment variable.
    Note: If you are connecting to a remote workspace, set the environment variable on the remote system and terminate all VS Code server processes. (For example, run ps -aux | grep vscode-server on the remote Linux machine to see the processes.)

Then, complete the following steps:

  1. Search for Environment Variables.
  2. Start Edit the system environment variables:
    edit environment variables.png

  3. Click Environment Variables:
    click env variables.png

  4. In the System variables section, click New:
    system variables new.png

  5. Enter the name of the new Variable name: NODE_TLS_REJECT_UNAUTHORIZED
  6. Then, specify 0 for the Variable value:
    0 variable name.png

    The new environment variable is defined.

  7. Click OK to leave the Environment Variables window:


  8. To make the environment variable effective in Visual Studio Code, close Visual Studio Code and start it again.

Connections to SAS Environments

Connect to a SAS Viya Server

Complete these steps to connect to a SAS Viya Server:

  1. Start Visual Studio Code.
  2. Press the F1 key.
  3. In the top-middle section of the screen, actions are displayed.
  4. Select SAS: Add New Connection Profile:
  5. Add connections to the SAS environments:
    add connection to sas env.png

  6. Enter a connection name and press the Enter key:
    new connection name.png

  7. Select the Connection Type:
    connection type.png

  8. Enter the base SAS Viya Server URL and press the Enter key.

    For example, you would enter something similar to the following:
    https://enter.the.base.URL.to.your.VIYA.server/ 

    Do not include SASStudio or SASLogon/login at the end as shown here: https://enter.the.base.URL.to.your.VIYA.server/SASStudio

    viya server url example.png

  9. The SAS Compute Context field is pre-filled. Press the Enter key:
    sas compute context.png

  10. Do NOT enter a Client-ID. Press the Enter key:
    client id.png

The connection is defined and active.

In the bottom left corner of the window, the active connection profile is displayed:

active connection profile.png

Log On to a SAS Viya Server

Complete these steps to log on to a SAS Viya Server:

  1. Click the SAS icon in the left panel.
  2. Click Sign in.
  3. Click Allow:
    allow visual studio code.png

  4. Click Open:


    The “Authorization Code” website for that server opens in a browser.
    Note: You might need to log on to the server with your user-ID and password first.

  5. Highlight (that is, select) the Authorization Code and press CTRL-C to copy it:
    autorization code.png
  6. Paste the authorization code in the required field in Visual Studio Code. Then, press the Enter key:
    authorization code vscode.png
    enter to confirm your input.png

The SAS Environment populates in the left panel:

sas env populates in left panel.png

Connect to a SAS 9.4 Server

Complete these steps to connect to a SAS 9.4 Server:

  1. Start Visual Studio Code.
  2. Press the F1 key.
  3. In the top-middle section of the screen, actions are displayed.
  4. Select SAS: Add New Connection Profile.
  5. Add connections to the SAS environments:
    add connection to sas env.png

  6. Enter a name for the connection. Then, press the Enter key:
    enter name for connection.png

  7. Select SAS 9.4 (remote – IOM) as the Connection Type:
    remote-iom connection type.png

  8. Provide the Server-Name of the SAS 9.4 Server (as in the SAS® Enterprise Guide® Connection). Then, press the Enter key:
    sas 9 server name.png

  9. Press the Enter key to accept the default port:
    accept the default port.png

  10. Enter the user name that you want to use to connect to the SAS 9.4 Server. Then, press the Enter key:
    user name for connection.png

 

The active connection is displayed in the bottom left corner of the Visual Studio Code window:

active connection bottom left corner.png

Log On to a SAS 9.4 Server

Complete the following steps to connect to the SAS 9.4 Server:

  1. Click the SAS Extension icon in the left panel.
  2. Enter the user's password.
  3. Press the Enter key:
    sas extension pw.png

    The SAS environment populates in the left panel:
    sas env populates in left panel 2.png

Connect to a Local PC SAS Installation

  1. Start Visual Studio Code.
  2. Press the F1 key.
  3. In the top-middle section of the screen, actions are displayed.
  4. Select SAS: Add New Connection Profile.
  5. Add connections to the SAS environments.
    add new connection profile.png

  6. Enter a name for the connection, Then, press the Enter key.
    name for connection.png

  7. Select SAS 9.4 (local) as the Connection Type.
    94 is connection type.png

Switch Server Connections

  1. Click the current server connection in the bottom left section of the Visual Studio Code window.
  2. In the top-middle section, a list of available connections is displayed.
  3. Select the connection that you want to use.
    select connection to use.png

Delete a Server Connection

  1. Press the F1 key.
  2. Select SAS: Delete Connection Profile.
    delete connection profile.png

  3. Select the connection profile that you want to delete:
    sas 94 local pc delete.png