Take SAS program editor abbreviations to the next level


Rick posted a tip today about using abbreviations in the SAS program editor window (often referred to as the "enhanced editor"). Defining abbreviations is a great way to save keystrokes and re-use "templates" of code that you've squirreled away. (One of Rick's readers also picked up on the tip, and added it to his blog.)

If you use SAS Enterprise Guide 4.3, you can define those abbreviations even easier, and you can call them up just like any other part of the SAS syntax, using the autocomplete features of the program editor. Here's how.

1. Open a SAS program window (by opening an existing program or select File->New->Program)

2. Select Program->Add Abbreviation Macro

3. In the Add Abbreviation Macro window, type a short name for your code snippet, and then add the code you want to substitute when the abbreviation is triggered. Bonus: the code field in this window also features the SAS program editor that helps you to complete the valid syntax.

4. To use the abbreviation, simply type the abbreviation within your program. The editor will automatically "suggest" the abbreviation as a possibility as you type, and you can press the spacebar to commit the selection, just as with any other suggested keyword. If you hover the mouse cursor over the suggestion, you can see a preview of the text that will be substituted in. Note that the abbreviation entry shows as a special item (green diamond instead of blue square in this case), as another hint that this element is different than the built-in syntax. (Were the autocomplete icons inspired by our bowl of Lucky Charms one morning? I'll never tell.)

You don't have to rely on the autocomplete feature of the editor to get to your abbreviation. You can do as Rick suggests and assign a shortcut key by selecting Program->Enhanced Editor Keys. However, I'd stay away from Ctrl+I, as that currently maps to what I call the "indenter servant" -- the SAS code formatter. (But hey, you can change that key assignment too!)


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. Pingback: This week in blogs: abbreviations, innovation and the holidays - SAS Voices

  2. Pingback: Implement BY processing for your entire SAS program - The SAS Dummy

  3. Pingback: 5 keyboard shortcuts in SAS that will change your life - The SAS Dummy

  4. James Willis on

    Hi Chris,
    In my Enterprise Guide Program editor window the abbreviation macro only works when I am at the beginning of the line and the line is blank. How do I make the EG program editor recognize my abbreviation macros anywhere on the editor page? My abbreviation macros work perfectly for me in my PC SAS "Enhanced Editor" window.

  5. Hi Team,

    I have one problem in once stored procedures that procedure link with Java.
    front end Java application (DMF) and back end SAS

    in Java ex_id and type_d two variables are there once we will add in java any variables we have to increment in dataset for the same. could you please give me any suggestions .


    • Chris Hemedinger
      Chris Hemedinger on

      Vasu -

      So you have a front-end Java (JSP?) app that tracks some variables, and you need a process for updating the back-end SAS data model when you also update the front-end? It's difficult to provide advice without details of your application design, but I'd guess you'll need to update the SAS program for the stored process and perhaps the data sets that support your data model. You could post the question to the Stored Processes community; be sure to provide as many details as you can so that the members can provide useful advice.

  6. Hi good article.

    Is there any possibility to share a banch of abbreviation macros in an easy way with my team? Or is the import/export action the only way to exchange it? I would like to have a general file with common abbr. macros for every team member, that change on all clients when the masterfile changed? It this anyway possible? (maybe offer the autoexec.sas or so?)

    Thank you and Bye

    • Chris Hemedinger
      Chris Hemedinger on

      The editor macros (including abbreviations) are stored in the Windows Registry. You can't share them as-is, but you can only import/export (Program->Editor Macros->Macros).

      Since they are stored in the Windows registry (ex for EG 7.1: HKEY_CURRENT_USER\Software\SAS Institute Inc.\Enhanced Editor\BIC_7.1\Editor Customizations\User Defined Macros), you could technically automate the import/export of these with registry scripts. But I don't have a ready example for that.

  7. Hi Chris,

    I have this issue in EG v 4.3 that my abbreviations are not carried over in subsequent sessions.
    Please consider that I use EG through Citrix URL. Can you suggest a solution or work around for this issue?

    • Chris Hemedinger
      Chris Hemedinger on

      These settings are stored in the Windows registry. It sounds like the registry must be "reset" with each invocation of EG from your URL. The only workaround I can think of is for your startup script to re-import the registry settings that contain the keyboard macros.

      As an alternative, you might try a 3rd party tool like AutoHotkey. I think AutoHotkey can be used even without admin privileges, and you can assign keyboard shortcuts/macros for any text or action.

    • Chris Hemedinger
      Chris Hemedinger on

      Searching internally, it looks like this is a bug that has just been fixed for an upcoming hotfix and also in the next release. You should be able to assign a key mapped to your macro, but the autocomplete might not work. Stay tuned for the fix!

      • I found that by going to Tools>Options>SAS Programs>Editor Options>Autocomplete and then deselecting Enable Autocomplete, the custom abbreviations will autocomplete again. The drawback is that it disables the other autocomplete features.

        Thanks for the update about the hotfix.

  8. Pingback: Ten SAS Enterprise Guide program editor tricks - The SAS Dummy

  9. Possible functionality add (if it doesn't already exist): tab stops like in VS Code Snippets.
    Ex: Abbreviation code -
    proc means nway missing noprint data={:1};
    class {:2};
    output out={:3} sum({:4})=;

    For each index (":1" for example) a tab or some other key will jump to that spot. This would add additional efficiency when adjusting the abbreviation code to fit the immediate task at hand.

  10. Thanks for sharing.
    It takes time to copy code and add abbrevation for each snippet. If I want to create the abbrevations or prompts for all sas code snippets in batches, how to do in the PC SAS?

  11. Pingback: 5 keyboard shortcuts in SAS that will change your life - The SAS Dummy

Back to Top