This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post. |
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!)
This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post. |