Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teaching Old Languages New Tricks: SAS & R meet AI

BEDAC Workshop, January 2026

Prerequisites

  • R runtime: Install from CRAN.
  • SAS access (for execution): SAS 9 or SAS Viya. Without a SAS server you still get syntax highlighting and linting for SAS.
  • GitHub Copilot subscription.

SAS Extension Setup

  1. In VS Code, go to the Extensions view (Ctrl+Shift+X or CMD+Shift+X or find and "Extensions" icon on the left of your screen), and type SAS.
    Select SAS: (by SAS Institute) – The official language extension for running SAS code and viewing datasets.
    Install extension.
  2. Open Command Palette: ( either F1 or Shift+CMD+P) or using menu: View -> Command Palette;
  3. Type: SAS: Add New Connection Profile
  4. Profile Type: Choose SAS Viya or **SAS 9.4 ** I chose "localhost", but depending on your installation you might need to select a different option.
  5. Once installed, you should see a "Running Man" icon in the opt right to execute your code. You should also see a SAS logo on the left-side of your VS Code window. Depending on your SAS installation type, you may need to sigh-in next time you open a VS Code.

R Extension Setup

  1. In VS Code, go to the Extensions view (Ctrl+Shift+X or CMD+Shift+X or find and "Extensions" icon on the left of your screen), and type "R" (make sure you use quotes around R) : Select R: (by REditorSupport) – Provides syntax highlighting, linting, and package management. Install this extension. If you are asked if you would like to install a "languageserver" R package during this process, select "Yes". If this option does not appear during installing this extension, make sure you install this R package afterwards.
  2. I recomment that you also install the "R Debugger" and "R Syntax" extensions as well;
  3. If you previously have not been asked to install the languageserver package, you need to install it now. Open a terminal window (if it is not opened already) and start R, by typing R at the prompt. Once R session has started, you can type install.packages("languageserver")
  4. Troubleshooting If you are unable to start an R session, you may need to specify the path to where R is installed on your computer. Find the Path to your R installation. On Mac, you can open a terminal window and type: which R. On a Windows computer, open R or RStudio and in the Console window type R.home("bin"). Copy this path and then open a "Command Palette" window and type Preferences: Open User Settings (JSON) and select the corresponding line. Make sure you select the (JSON) option, not the (JSONS) option. At the bottom of the file, before the last { bracket, add the following lines:
    "r.rterm.option": [
        "--no-save",
        "--no-restore",
        "--r-binary=/your/path/to/R",
    ],

If the file is empty, make sure you add the {} brackets around your inserted line, so the final file, looks like:

{
    "r.rterm.option": [
        "--no-save",
        "--no-restore",
        "--r-binary=/your/path/to/R",
    ],
}

Make sure that the path of the --r-banary option is set to your path. On Windows computers, the path will look like C:\Program Files\R\R-4.5.2\bin\x64\R.exe. Make sure that you change the backslash characters \ to the forward slash characters / or use double-slash characters \\.
On Mac computers the R installation path may look like: /usr/local/bin/R.

VS Code R Help: https://code.visualstudio.com/docs/languages/r

Optional: You may want to set your R to use Radian. This will enable color-code-highlighting in your terminal window.


Setting up the GitHub Copilot

  1. Go to the Extensions view by clicking the square icon in the Activity Bar on the side, or by pressing Ctrl+Shift+X.
  2. Search for "GitHub Copilot" in the search bar.
  3. Select the official GitHub Copilot extension (and GitHub Copilot Chat).
  4. Click the Install button for the selected extensions.
  5. Once installed, the extension will prompt you to sign in to your GitHub account to activate it:
  • A pop-up may appear automatically asking you to Sign in to use Copilot. Select this option.
  • Alternatively, you can click the "Copilot icon" in the status bar at the bottom of the VS Code window (it might have a sign-in prompt) and select Set up Copilot or Sign in.
  • You can also open the Command Palette (Ctrl+Shift+P) and type "GitHub: Sign In" to manage your accounts.
  1. Authorize VS Code:
    • A browser window will open, redirecting you to a GitHub authentication page.
    • Sign in with your GitHub credentials if prompted.
    • Click "Authorize Visual Studio Code" (or Continue and then Allow) to grant the necessary permissions to the GitHub Copilot extension.
    • You may see a prompt in the browser asking to open the link in Visual Studio Code. Click "Open Visual Studio Code" (or a similar confirmation) to return to the application.
    • Back in VS Code, a final pop-up may appear asking to allow the extension to open a URI. Click Open.

Setting Your "Personal Agent"

In VS Code, your "Personal Agent" is powered by Custom Instructions. This ensures Copilot understands your specific coding standards (e.g., "Use Tidyverse for R" or "Always include a LIBNAME statement in SAS").

Setup:

  1. Open Settings -> Settings and in the search bar, type: "GitHub Copilot Instruction File". Make sure that the corresponding checkbox (Controls whether code instructions from .github/copilot-instructions.md) is checked.
  2. Create the .github sub folder in the root of your project folder.
  3. Inside .github, create a file named copilot-instructions.md.
  4. Use natural language, add your rules. For example:
    "When writing R, prefer the pipe operator |> and the dplyr package. For SAS, always use upper-case for PROC and DATA steps and include comments for every DATA step."

Global Instructions:
If you want these rules (or some of these rules) across all projects:

  1. Go to Command Palette and search for Chat: New Instructions File and select it.
  2. Select "User Profile" or "User Data" in the drop-down menu when prompted to create the file in your global settings folder.

VS Code Cheat Sheet: SAS, R, & Copilot

Action Windows / Linux macOS
The Essentials
Open Command Palette Ctrl + Shift + P Cmd + Shift + P
Open Settings (UI) Ctrl + , Cmd + ,
Open Integrated Terminal Ctrl + ` Ctrl + `
Toggle Sidebar Visibility Ctrl + B Cmd + B
R Programming
Run Selected Line/Code Ctrl + Enter Cmd + Enter
SAS Programming
Run Selected SAS Code F3 (or Alt + S) F3 (or Option + S)
Clear SAS Log Ctrl + L Cmd + L
GitHub Copilot
Open Copilot Inline Chat Ctrl + I Cmd + I
Open Copilot Chat Sidebar Ctrl + Alt + I Cmd + Option + I
Accept Ghost Text (Suggestion) Tab Tab **
Next/Prev Suggestion Alt + [ or ] Option + [ or ]
Git & Version Control
Open Source Control Tab Ctrl + Shift + G Ctrl + Shift + G
Markdown & Documentation
Open Preview to the Side Ctrl + K then V Cmd + K then V
Toggle Full Preview Ctrl + Shift + V Cmd + Shift + V

Tips and Tricks

  1. To view a Markdown file in the VS Code, click the "Open Preview" button: Preview Markdown

About

Data Science Conversations - VS Code Demonstration

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages