BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SasStatistics
Pyrite | Level 9

In SAS (Atleast SAS Enteprise Guide), it is possible to record Macros and assign keys. When recording Macros, you have to manually write down the code you want to store. 

So for example, I could record a Macro and assign it a key so that when I press Ctrl + 1  (I chose that keyboard shortcut), the following text appears: 
"This is My Macro That I recorded".  

I was thinking, that it should (?) be possible to just paste in the text "This is My Macro That I recorded" (instead of having to write it manually) and then assign it a keyboard shortcut such as Ctrl + 1, this would be very handy if my Macro recording for instance contains 50 rows of code. 


Any ideas? 

1 ACCEPTED SOLUTION

Accepted Solutions
SasStatistics
Pyrite | Level 9

In Enterprise Guide, go to: 
Program > Manage macros and snippets. There you can for instance also assign keyboard shortcuts. 


View solution in original post

4 REPLIES 4
ballardw
Super User

If you look at the actual keyboard macro you will likely see what that isn't likely to fly. I don't use EG but the older Display manager would let you use the Tools>Keyboard macros>macros menu to bring up a window with your macros. Then you could highlight a macro and select edit to see the actual macro. For macros that insert text you would see:

Insert character ('d')

Insert character ('a')

Insert character ('t')

Insert character ('a')

where the word "data" was to appear. Plus "insert carriage return" for the next line.

 

So editing keyboard macros as you suggest is probably not where you want to be. Look at custom tasks or code snippet tools.

 

SasStatistics
Pyrite | Level 9

Thanks ballardw. Do you know if it then is possible to "create a keyboard shortcut" that simply writes out the following:

"This is my Code that I have put as a Keyboard shortcut" ?

Code snippets seems to be a solution, but reading the documentation it only works for SAS Studio: "Code snippets enable you to quickly insert SAS code into your program and customize it to meet your needs."


Code snippets exactly does what I would like, as demonstrated by the picture (you can insert SAS code automatically): 

SasStatistics_0-1623915980478.png

 

Source: https://documentation.sas.com/doc/en/webeditorcdc/3.7/webeditorug/n002bgjjez3z63n16y88kjsobrha.htm 

 



FreelanceReinh
Jade | Level 19

Hello @SasStatistics,

 

If the purpose of your (Enhanced Editor) macro is just to write constant text, it's easier to create it as follows than to record it:

  1. In SAS EG open a Program window.
  2. From the menu select Program → Editor Macros → Macros.
  3. Click "Create...".
  4. Enter a keyboard macro name (and, optionally, a keyboard macro description).
  5. From command category "Edit" select "Insert a string".
  6. Press the arrow button in the middle of the "Create Keyboard Macro" dialog. This opens the "Insert String" dialog window.
  7. Paste your text into that window and confirm with OK.
  8. Click "OK" in the "Create Keyboard Macro" dialog.
  9. Click "Assign keys..." to assign a shortcut key as usual.

 

(In the traditional Display Manager interface it's the same procedure except that the menu items are Tools → Keyboard Macros → Macros... .)

SasStatistics
Pyrite | Level 9

In Enterprise Guide, go to: 
Program > Manage macros and snippets. There you can for instance also assign keyboard shortcuts. 


SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 4 replies
  • 1250 views
  • 1 like
  • 3 in conversation