SAS Communities Library

We’re smarter together. Learn from this collection of community knowledge and add your expertise.
BookmarkSubscribeRSS Feed

SAS Extension for Visual Studio Code - Deep Dive: settings.json

Started ‎02-28-2024 by
Modified ‎02-28-2024 by
Views 1,624

During my recent Ask the Expert webinar (on-demand link) on the SAS Extension for Visual Studio Code (VS Code) one question came up: Can you please share the example settings.json? The answer is of course yes (and if you are only interested in that, skip to the end), but I thought it is a great opportunity to dive deep into it. 

 

If you are looking for a general article on the SAS Extension for VS Code check out this article.

 

What is a setting.json and where can I find it?

 

Configurations inside of VS Code are stored in JSON format. And the settings.json is exactly that store, while there is a global setting.json, if you go to one specific Extension you will get to interact with a settings.json that is reduced. JSON So how do we get there? Go to Manga (cogwheel icon) > Settings > Extensions > SAS > Edit in settings.json - or follow this GIF:

VS-Code-Settings-JSON.gif
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
    • Chapters
    • descriptions off, selected
    • captions off, selected
      (view in My Videos)

       

      Why would you want to edit the settings.json directly?

       

      That is a fair question, because a lot of the options can be changed through the visual UI that we see just before going to edit the settings.json. And I strongly recommend that you use the visuals for adding settings or profile where you can, as the interfaces are easy to use and have great context information that will help you to better understand the context of each option.

       

      Splitting the settings.json into part.

       

      First we will only focus on the attributes that start with SAS, that is because these settings actually come from the SAS Extension. Depending on what other extensions you have installed you might see many additional attributes in there.

       

      Second will split the SAS attributes into two camps:

      1. SAS.connectionProfiles

      2. The rest of the settings, all of them can be edited through visuals. I will not be explaining these here, because as stated above I think they are well explained in the visual part and I would only be reiterating these explanations here.

       

      SAS.connectionProfiles

       

      This section holds all of your connection profiles to different SAS environment. Here we first see the activeProfile which contains the name of the last selected connection profile. After that we see the profiles, which will contain entries for each profile that you have created. Note that as I write this there is currently four types of profiles available SAS Viya, SAS 9.4 (remote - SSH), SAS 9.4 (remote - IOM) and SAS 9.4 (local) - each of the entries will look slightly different depending on the type.

       

      For creating/updating/deleting profiles I recommend that you use the corresponding commands (SAS: Add New Connection Profile, SAS: Update Connection Profile and SAS: Delete Connection Profile). But if you want to add specifc auto exec code or change SAS options within the context of your profile you are correct in going to the settings.json.

       

      Let's assume we have the following:

       

      {
          "SAS.connectionProfiles": {
              "activeProfile": "SAS Viya",
              "profiles": {
      1           "Profile Name": {
      2               "connectionType": "",
      3               "autoExec": [
      4                   {
                              "type": "line",
                              "line": "%put Hello World;"
                          },
      5                   {
                              "type": "file",
                              "filePath": "/path/to/local/example.sas"
                          },
      6                   ...
                      ],
      7               "sasOptions": ["pageSize max", ...]
                  }
                }
              }
          }
        ]
      }
       
      1. Here you see the name of the profile.
      2. I have left the connection type blank for brevity.
      3. Now we get to the choice part, we create a new pair that is called autoExec and it contains an array of content.
      4. We start a first object to become part of our autoexec. We specified the type as line, which means we have to add an additional key:value pair called line which contains one line of SAS code that will be run as part of our autoexec.
      5. Here we have a second object which is of type file and then we have to specify a filePath that refenreces a .sas file on our local machine which will be submitted.
      6. Of course you can have as many objects in here as you need, note that they will be run in the order that they are specified here from the first element of the array to the last.
      7. You can also add a new pair called sasOptions which takes as an input an array of strings where each string is a SAS option that you would like to set. Seperate each String with a comma and they are also run in order.

       

       

      The Full Example settings.json

       

      {
          "SAS.connectionProfiles": {
              "activeProfile": "SAS Viya",
              "profiles": {
                  "SAS Viya": {
                      "connectionType": "rest",
                      "endpoint": "https://sasviyaHostURL",
                      "context": "SAS Job Execution compute context",
                      "clientId": "leave empty for the default client (only available on SAS Viya 4)",
                      "clientSecret": "leave empty for the default client (only available on SAS Viya 4)",
                      "autoExec": [
                          {
                              "type": "line",
                              "line": "%put Hello World;"
                          },
                          {
                              "type": "file",
                              "filePath": "/path/to/local/example.sas"
                          },
                          ...
                      ],
                      "sasOptions": ["pageSize max", ...]
                  },
                  "SAS 9.4 IOM": {
                      "connectionType": "iom",
                      "host": "sasServerAdress",
                      "port": 8591,
                      "username": "yourSASUsername",
                      "sasOptions": [],
                      "autoExec": []
                  },
                  "SAS 9.4 Local": {
                      "connectionType": "com",
                      "host": "localhost",
                      "sasOptions": [],
                      "autoExec": []
                  },
                  "SAS 9.4 SSH": {
                      "connectionType": "ssh",
                      "host": "sasServerAdress",
                      "saspath": "/path/to/sas/executable",
                      "username": "yourSASUsername",
                      "port": 22,
                      "sasOptions": [],
                      "autoExec": []
                  }
              }
          },
          "SAS.results.singlePanel": true,
          "SAS.flowConversionMode": "Node",
          "SAS.results.sideBySide": true,
          "SAS.results.html.enabled": true,
          "SAS.results.html.style": "(auto)",
          "SAS.log.showOnExecutionStart": true,
          "SAS.log.showOnExecutionFinish": true,
          "SAS.userProvidedCertificates": [
              "/path/to/Certificate", ...
          ]
      }

       

      Version history
      Last update:
      ‎02-28-2024 01:02 PM
      Updated by:
      Contributors

      sas-innovate-white.png

      Our biggest data and AI event of the year.

      Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

      Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

       

      Register now!

      SAS AI and Machine Learning Courses

      The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

      Get started

      Article Tags