SAS® and R

Best of Both Worlds

Abbr. [Update]

leave a comment »

Have you been using the same SAS procedures or SAS functions over and over again, but for some reason never been able to remember the correct syntax, or do you wish you can cut down on repetitive typing, and focus more on thinking?  SAS Enhanced Editor actually has a little tool built in to help you achieve just that.

A SAS abbreviation is a character string defined by you so that when you type the string in the Enhanced Editor window, the string is automatically substituted with a longer text string. Abbreviations are actually keyboard macros that insert one or more lines of text.

1. Create Abbreviation
Just press “Ctrl + Shift + A”, or use the menu “Tools –> Add Abbreviation”In the Abbreviation field, type the name of the abbreviation. In the Text to insert for abbreviation field, type the text that the abbreviation will expand into. Then click OK. For example, here we type in the syntax for function IFN.  We name this abbreviation ifn, and that is the “code word” you type in the Enhanced Editor to invoke this keyboard macro.

Whenever you want to use an abbreviation, simply type in the name of the abbreviation while in the Enhanced Editor. As soon as the last letter of the abbreviation has been entered, a small pop-up ‘tip’ text box containing the first few words of the abbreviation is displayed. If at that point you press the TAB/Enter key the name of the abbreviation will be replaced by the text that you stored.

2. Export/import abbreviation
You can also export or import your abbreviations so you have access to them on multiple machines. Go to “Tools –> Keyboard Macros –> Macros”.

A window opens where you select the abbreviations to export. If you want to select more than one, hold down the CTRL key on your keyboard as you click on each abbreviation. Click “Export”, SAS will automatically select the necessary file type Keyboard Macro Files (*.kmf). Name the file anything you want. SAS will then create the export file for you. And if you want to import KMF file, click “Import.”Voila! After you set up the abbreviation once, you can recall it again and again. This might be especially useful in adding program header block, and it can also reduce effort in looking up syntax for functions, statements, or procedures you are prone to forget to avoid interruption to your programming flow. Hope this trick is useful to you.

[Update] Here is a video from SAS® software solution consulting firm Amadeus Software about Using Abbreviations.

Advertisements

Written by sasandr

May 16, 2012 at 2:37 pm

Posted in SAS

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: