BookmarkSubscribeRSS Feed

How to use VS Code with SAS OnDemand for Academics

Started ‎02-08-2024 by
Modified ‎02-16-2024 by
Views 4,025

The VS Code with the SAS extension is becoming a top tier programming client for SAS users. It has many of the features that programmers expect, such as syntax suggestions, built-in syntax help and doc, and the ability to connect to any SAS environment. New SAS learners who rely on SAS OnDemand for Academics had been left out of this experience, but no more! With the latest updates to the SAS extension, you can connect VS Code to your account in SAS OnDemand for Academics (sometimes-but-not-officially called "SODA"). Once connected, you can run code and see your results within VS Code -- no need to log in via a browser.

 

VS Code with the SAS extension, connected to SODAVS Code with the SAS extension, connected to SODA

How to connect VS Code to SODA

Before we get into it, I'll admit that this connection type is available only on Windows. If you're running VS Code on a Mac or other device type, this connection won't work. It relies on the Windows-only "SAS Integration Technologies client", working similar to SAS Enterprise Guide. Mac users: I'm sorry. (You can still use the SAS extension to edit and manage your SAS programs, and you can connect to SAS Viya environments, but you won't be able to connect to SAS 9.4 environments with this method.)

 

This connection is made possible by two innovations:

Setting up the prereqs

Before you get started, you will need these prerequisites (all free):

  • An account to log into SAS OnDemand for Academics. This is free for any learner and for non-commercial uses.
  • VS Code installed on your Windows device. Add the SAS Extension for Visual Studio Code while you're at it.
  • The SAS Integration Technologies Client for Windows -- installed. This is already installed with any local SAS applications like SAS 9.4 for Windows or SAS Enterprise Guide. It's also available as a free download from support.sas.com. (Be sure to get the most recent version.)

To define your VS Code/SAS profile, you will need to gather the following information from your SODA account:

  • the "home region" of your SODA connection. This is displayed at the top of the Welcome page after you sign in.
  • your user ID. This is available in the dropdown menu next to your profile name
  • your SODA password. This is also your SAS Profile password. 

For example, in this screenshot you can see that my home region is "United States 1" and that my user ID is the value beginning with "u3":

 

Welcome screen with home region, profile detailsWelcome screen with home region, profile details

Finding your server name by host region

SAS OnDemand for Academics is a large-scale SAS environment that has hundreds of thousands of active users around the globe. The environment is divided into multiple regions with multiple server hosts. Your account is accessible only from the servers in your assigned region, so you need to match your home region with the server name in order to sign in with the SAS extension.

 

The server/region mapping is defined in the instructions for open-source connections. I've added the current values here for reference, but note that these are subject to change.

  • US Home Region 1: odaws01-usw2.oda.sas.com
  • US Home Region 2: odaws01-usw2-2.oda.sas.com
  • European Home Region 1: odaws01-euw1.oda.sas.com
  • Asia Pacific Home Region 1: odaws01-apse1.oda.sas.com
  • Asia Pacific Home Region 2: odaws01-apse1-2.oda.sas.com

Define your profile in the SAS extension

With all of the information gathered, we're now ready to add a SODA profile to the SAS extension in VS Code. Complete these steps in your VS Code session.

 

  1. Press Ctrl+Shift+P or F1 to show available commands, and select "SAS: Add New Connection Profile".
    _1_addprofile.png
  2. Assign a name for this connection profile. I've used "SODA" here.
    _1a_setname.png
  3. Select the SAS 9.4 (remote - IOM) connection type.
    _2_selecttype.png
  4. Enter the server name that is associated with your host region. Then confirm the Port number (always 8591 for this environment).
    _3_servername.png
    _4_portnumber.png
  5. Enter your SAS OnDemand for Academics username.
    _5_username.png

That's it! Once the profile is defined it should appear as your active SAS profile as indicated in the status area in the bottom of your VS Code window.

activeprofile.png

 

Open a SAS program file, or create a New SAS file with VS Code, then click the "running person" (or press F3) to submit it.

submit.png

 

The first time that you run a program, you'll be prompted for your SAS OnDemand for Academics password. Type it in the field and press Enter, and your program will run in your SODA account!

_6_password.png

 

Because your program is running in your SAS OnDemand for Academics account, your code can reference any data or files that you have access to in that environment. As your program completes, you'll see the SAS Log in the output area of VS Code, and any ODS HTML results will automatically display in a new Results window.

 

Anatomy of your SAS environment in VS CodeAnatomy of your SAS environment in VS Code

Limitations

At this time, the SAS 9.4 - Remote IOM connection does not support navigation for SAS libraries, viewing data sets with a built-in viewer, or remote file access/management. These features are supported for the SAS Viya connection type, and they are actively being worked on for SAS 9.4 - Remote IOM. Coming soon!

Comments

Thanks Chris, great article!  I finally saw VS Code in action as a SAS IDE at SAS Explore last year, and it was very exciting! I came home an installed VS code and connected it to my local SAS 9 session, and really enjoyed using it.  I'll definitely try connecting it to SODA.  Also looking forward to seeing VS Code in action in the upcoming ATE on SAS Viya Workbench! https://www.sas.com/en_us/webinars/sas-viya-workbench.html

I am getting an error. The SAS integration technologies client has been installed into my system, still, I get the below error

 

Rajaram_0-1707899025688.png

 

Hi @Rajaram - I suggest you post this to the project Issues on GitHub. The team is very responsive. This could be an issue with the particular version of VS Code (older versions sometimes cause issues).

@Rajaram Thanks to your report and a few others, the issue has been addressed and new version was published!

Tom

If you are not sure where your SAS Workspace Server is but are using SAS/Studio already you might be able to query your SAS Metadata Server to find it.  If you run the code in this SAS documentation example.

 https://support.sas.com/documentation/cdl/en/lrmeta/60739/HTML/default/viewer.htm#a003272745.htm You should see it in the report it creates. 

 

For example in the example results on that page it shows this line:

Tom_0-1708043644303.png

Which showing that the server address is myserver and the port number is 8591.

 

Awesome, will try it

Hello!
SAS throw me an error of connection to ODA.
My config:

"SAS.connectionProfiles": {
        "activeProfile": "SODA",
        "profiles": {
            "SODA": {
                "connectionType": "iom",
                "sasOptions": [],
                "host": "odaws01-euw1.oda.sas.com",
                "port": 8591,
                "username": "my user ID here"
            }
        }
    }

Somebody any thoughts, please?

@JanKwiatkowski You have the Integration Technologies client installed? If so, you should be able to run itconfig2.exe from your PROGRAMFILES\SASHome\Integration Technologies folder and test the workspace connection. Note the encryption type has to match what the server supports/expects.

 

itconfig.png

Problem is here .

Ksharp_2-1708143622065.png

 

I am getting following error

 

System.Runtime.InteropServices.COMException (0x80042002): <connectionAttempts>
<connectionAttempt>
<description>Connection timed out. A connection attempt failed because the SAS Server did not properly respond after a period of time, or established connection failed because connected host has failed to respond. </description>
<status>0x8007274c</status>
<saslogin>rajahram</saslogin>
<sasmachinednsname>odamid-apse1.oda.sas.com</sasmachinednsname>
<sasport>8591</sasport>
<sasclassid>440196D4-90F0-11D0-9F41-00A024BB830C</sasclassid>
<sasprogid>SAS.Workspace.1.0</sasprogid>
<threadid>11056</threadid>
<name>test</name>
</connectionAttempt>
</connectionAttempts>
at SASObjectManager.IObjectFactory2.CreateObjectByServer(String Name, Boolean synchronous, IServerDef pIServerDef, String LoginName, String Password)
at SAS.BI.Itconfig.Library.ServerTests.SASServerTest.CreateConnectionWithObjectFactoryMulti()
at SAS.BI.Itconfig.Library.ServerTests.SASServerTest.CreateConnection()

@Rajaram It looks like the server is not reachable from your client machine. Perhaps you are working within a network with a firewall? While your browser might have the ability to route internet traffic through a proxy (so you can get to SODA), maybe other local applications cannot. I'm guessing here, based on other situations I've seen.

@ChrisHemedinger , hello!
Than you for your answer! No, I haven't had installed Integration Technologies client, I have acces to SODA to learn SAS Programmingand now I Try to connect to SODA with VS Code like discribed, but connection is failed.

[Error: There was an error executing the SAS Program. See [console log](command:workbench.action.toggleDevTools) for more details.
at Hx.onShellStdErr ("my local path"\.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)]


Now I can only select SASProprietary Encryption method like Ksharp mentioned above.

Note: If you do not have a license for SAS/SECURE, you can only specify the SASProprietary algorithm.

https://support.sas.com/rnd/itech/doc9/admin_oma/security/security_encrypt.html 

 

So users who have no license still cannot be connected in vscode?

At least I can't.

@JanKwiatkowski @sxjeru I'll look into this. The additional cryptography methods are part of a SAS/SECURE client that may not be part of the Integration Technologies client download.

H Chris.  I'm commenting here so that I get updated - in case a fix or workaround gets added - to get this working without a SAS/Secure license. 

Version history
Last update:
‎02-16-2024 10:37 AM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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