BookmarkSubscribeRSS Feed
djsas1
Calcite | Level 5

I would like to be able to insert words from a pre-defined list into my SAS code (well, into comments, but could obviously go in as code and then be commented out). This would be used in program headers as 'tags' for the program.

 

I am posting as I am wondering if this is possible? I have looked around at snippets etc, and I have seen some solutions that unfortunately require SAS Studio.

I am using base SAS 9.4. Switching to SAS Studio is not an option for the wider team that I would like to implement this with. 

djsas1_0-1754309026663.png

 

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

In SAS 9.4, you can create abbreviations. Type a few letters, and a large block of code (whatever you want) is inserted into your code. I use it because the databases here have some variable names that I often mis-spell, so now, for example, I type the 3 letter abbreviation cyc and press ENTER and SAS includes in my code a much longer variable name that is always spelled properly.

 

In the SAS 9.4 Enhanced Editor, select Tools->Add Abbreviations. From there, I leave it as a homework assignment for you to figure out what to do next.

--
Paige Miller
FreelanceReinh
Jade | Level 19

Hello @djsas1 and welcome to the SAS Support Communities!

 

I second PaigeMiller's suggestion.

 

For a moderately long list of words (or other items) an implementation like the following might be convenient:

Abbreviation  Item  
--------------------
°h            Lorem 
°hh           ipsum
°hhh          dolor
... and so on ...

So, you would type some starting character (I suggested "°" because it is rarely used elsewhere) and then step forwards through the list of words by pressing the same key ("H" in the example, for "header") repetitively. Use the Backspace key to go back one or more steps. Confirm with the Return key once the desired word is displayed in the Word Tip. (See also the documentation.) For convenience, you may want to include a trailing blank at the end of each word.

Tom
Super User Tom
Super User

Are you using Display Manager in SAS 9.4?

Are you running on Windows?  If so you can use the "Enhanced" Editor and it does have some tools for that.

 

If you are not running on Windows (or just not using that editor) then you might try programming a KEY. https://support.sas.com/documentation/onlinedoc/sasc/doc700/html/tw5201/z1116812.htm

And you can always write a command macro.  For example I have a macro I have been using for 30 years to allow me to paste the list of variables from a dataset into the editor.

%macro gks(data,alias)/cmd;
/*-------------------------------------------------------------------
Generate KEEP statement (or SQL SELECT statement)

To generate a SELECT statement, set ALIAS to the table alias or to .
for no alias.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 278 views
  • 3 likes
  • 4 in conversation