Submit a Help Request (804) 828-2227 | itsc@vcu.edu
Send us an e-mail
Get help quickly

Call (804) 828-2227 for immediate assistance.

Creating Keyboard and Toolbar Shortcuts in SAS

You can create SAS keyboard shortcuts and toolbar buttons to instruct SAS to perform a set of tasks.  For example, if you like to clear your log, output, and results windows before executing new commands, you might set up a shortcut or button to instruct SAS to do all of those tasks, with just the press of a key or click of a button.

You can create SAS keyboard macros to let you easily insert frequently used text into the Enhanced Editor window. For example, you might use this to insert the commands for a favorite Proc step or Data step.

These facilities can be great time savers.

How to Create a Keyboard Shortcut

  1. Make sure the Enhanced Editor window is the active SAS window.
  2. From the toolbar, select Tools --> Options --> Keys.
  3. Scroll down to the keystroke you would like to assign to the series of tasks, looking for a keystroke that has no current assignment.  For example, scroll down to F12, which represents the F12 key on your keyboard, or to SHF F12, which represents pressing Shift-F12.
  4. Add your desired task commands under the Definition heading for that keystroke.  For example:

          log; clear; output;clear; odsresults; clear; wpgm; submit;

    Those commands instruct SAS to go to the Log window and clear it, then go to the Output window and clear it, then go to the Results Viewer window and clear it, then go to the program editor window and submit the code found there.  See the SAS documentation for additional commands that can be used in keyboard shortcuts.

  5. Close the Keys window.

Now, pressing the assigned keystroke will perform the assigned set of commands. The keystroke is available in the Log, Output and Enhanced Editor windows

Notes about creating SAS shortcuts:

  • If there are multiple editor windows open, the keystroke will resubmit code for the editor window that the user is currently in.
  • If there are multiple editor windows open and the user is not in an editor window, the keystroke will submit whatever program code that is highlighted.
  • If no program code is highlighted, the keystroke defaults to the first editor window.
  • This assignment will remain until it is changed or deleted.  (The shortcut is retained even when you close/open your SAS® session).

How to Create a Toolbar Button

  1. Make sure the Enhanced Editor window is the active SAS window.
  2. From the toolbar, select Tools --> Customize.
  3. In the pop-up window, choose the Customize tab.
  4. Select the Add tool icon (left-most icon in the second row).
  5. Enter the series of commands in the command box:
       For example:  log; clear;odsresults;clear;output;clear;wpgm; submit;
  6. Type a description of your icon in the Help text box
       For example: Clears log and output windows and resubmits code in editor window
  7. Select the Change Icon button (third icon in the second row).
    1. Choose the icon you would like to associate with your series of commands.
    2. Select OK.
  8. When asked "Do you want to save your changes to SASUSER.PROFILE.SASEDIT_MAIN?",
    Select YES you would like to save the changes made.

Notes about creating toolbar buttons:

  • The new icon should now appear on your Enhanced Editor window toolbar.
  • If there are multiple editor windows open, the icon will submit code from the editor window that the user is currently working in.
  • The Output window and the Log window each have their own toolbars. 
    • Should you want a shortcut icon in both the Output and Log windows, you will need to create the icon using the steps above once in each window.

How to Create a Keyboard Macro

An SAS keyboard macro can help you easily insert a command or set of commands (or any text) into the Enhanced Editor window.  This can be a great time saver.  For example, you might want to use this to insert the commands for a favorite Proc step or Data step.

Once a macro is created, its text can be inserted into the editor window at any time by just typing the macro's abbreviation (name) or by pressing a keyboard shortcut that you have assigned to the macro.

To create a macro, do the following:

  1. First, copy into the Windows clipboard the text that you want to assign to this macro.  For example, type that text into the editor window, select the text with your mouse, then right-click it and choose 'Copy'.  Any amount of text can be assigned.
  2. Make sure the Enhanced Editor window is the active SAS window.
  3. Now display the Tools menu and select 'Add Abbreviation' (or press the key combination Control-Shift-A).  This will display the Add Abbreviation window.  In this window, do the following:
    1. In the Abbreviation box, type a short abbreviation for the macro.  Later, when you want to insert your text, you will type this abbreviation in the editor window.
    2. In the large box, right-click and choose 'Paste', to insert your desired text (that you had copied to the Windows clipboard in step 1 above).
    3. Click OK.

Your macro is ready to use.  In the editor window, whenever you now type your macro's abbreviation, you will see a pop-up display of the text stored in the macro.  To insert that text into the editor window, press the Tab or Enter key.  Or, you can just keep typing, if you do not want to insert the macro's text.

Later, if you wish to edit your macro or assign a keyboard shortcut to it (so that pressing that keyboard shortcut will instantly insert the text), display the Tools menu and select 'Keyboard Macros' and then 'Macros' (or press the key combination Control-Shift-M).  The Keyboard Macros window will display so that you can modify this and any other macros that you have created.

For more information, please see (for example) Keyboard Macros.



This article was updated: 01/24/2017