Running SAS Code by Task
Run selected code or all code in active editor
- Open the command palette (
F1
, orCtrl+Shift+P
on Windows or Linux, orShift+CMD+P
on OSX) and execute theTasks: Run Task
command. - Select the sas task category and then select the sas: Run sas file task.
- This task automatically runs selected code or all code in active editor (depending on whether you have selected any code).
Custom task to run specified SAS file in workspace
- Open the command palette (
F1
, orCtrl+Shift+P
on Windows or Linux, orShift+CMD+P
on OSX) and execute theTasks: Configure Task
command. - Select sas: Run sas file task.
- The
tasks.json
file opens with an initial task definition:
{
"version": "2.0.0",
"tasks": [
{
"type": "sas",
"task": "Run sas file",
"problemMatcher": [],
"label": "sas: Run sas file"
}
]
}
- Add the file field and assign a SAS file name to it.
- Update the label field. Here is an example of the final task definition:
{
"version": "2.0.0",
"tasks": [
{
"type": "sas",
"task": "Run sas file",
"file": "my.sas",
"problemMatcher": [],
"label": "run my.sas code"
}
]
}
- Save
tasks.json
. - This custom task can be run by Run Tasks... in the global Terminal menu
Note:
- If you do not specify a file property or you assign an empty string to the file property in your task definition, the custom task will use the default properties of a built-in task.
Custom task to run sas code with preamble and postamble added
- Open the command palette (
F1
, orCtrl+Shift+P
on Windows or Linux, orShift+CMD+P
on OSX) and execute theTasks: Configure Task
command. - Select sas: Run sas file task.
- Add preamble and/or postamble properties and enter the SAS code.
- if a file is specified, the preamble and postamble will be added in the code from this file when this task is executed.
- If file is absent, then preamble and postamble will be added in the selected code (if you have selected code) or all code in active editor when this task is executed.
{
"version": "2.0.0",
"tasks": [
{
"type": "sas",
"task": "Run sas file",
"file": "code.sas",
"preamble": "some code*",
"postamble": "some code*",
"problemMatcher": [],
"label": "Run additional code"
}
]
}
Assigning keyboard shortcuts to tasks
If you need to run a task frequently, you can define a keyboard shortcut for the task.
For example, to assign Ctrl+H
to the run additional code task from above, add the following to your keybindings.json file:
{
"key": "ctrl+h",
"command": "workbench.action.tasks.runTask",
"args": "Run additional code"
}