BookmarkSubscribeRSS Feed

Quick Tips for SAS Enterprise Guide Users Part 2: Working with the Program Editor

Started ‎05-31-2019 by
Modified ‎06-13-2019 by
Views 7,892

You might have moved to SAS Enterprise Guide from another programming interface and prefer coding to point-and-click. The Program Editor in SAS Enterprise Guide can be customized to make your coding experience easy and familiar.

 

In  the second part of the series "Quick Tips for SAS Enterprise Guide Users", you will learn tips for using the program editor to its full advantage.

 

1.     Turn on line numbers

 

Line numbers are not turned on by default in the Program Editor. To turn on line numbers, select Tools-->Options.  Open the SAS Programs panel and click Editor Options. In SAS Enterprise Guide 8.1, it’s even easier – just right-click in the Program Editor and select Show line numbers.

 

 

2.     Automatically Format Code

 

Sometimes you are so “on a roll” with writing code that you don’t want to take the time to indent your code and make it readable. SAS Enterprise Guide can help! Right-click in the Program Editor and select Format code, and your code will transform into a more readable and structured format. You can also press Ctrl+I to format the code.

 

 

3.     Copy a column

 

There are times when you want to copy lines of code and reuse them. But you might not want the whole line, just part of it. Rather than copying the lines and deleting the part you don’t want, press Alt+left mouse to highlight the part you want, and then copy it.

 

 

4.    Autocomplete

 

You may notice when you start to type a keyword that the editor tries to "predict" the word before you complete it, or it will suggest valid options for libraries, datasets, variables, etc. This is the autocomplete functionality. You can customize this functionality or turn it off completely if you find it distracting. You can customize it through Tools --> Options --> SAS Programs --> Editor Options --> Autocomplete. 

 

 

5.    Abbreviation Macros

 

You probably have some code that you run regularly.  Instead of retyping it each time or copying and pasting, you can create an abbreviation macro. This associates an abbreviation or user-defined keyword with the code you designate and inserts it into your program editor. Simply select and copy the code, then go to Program --> Add Abbreviation Macro,  create your abbreviation and paste the code.  Now when you type the abbreviation in the editor, you can select and automatically insert your code! 

 

 

6.     DATA Step Debugger

 

You will get a syntax error in the log when you have an error in your code, but it’s harder to find errors in the code logic. The code might run but it doesn’t produce the results you expect. You can use the DATA Step Debugger to find the logic errors in your code.

Enable the debugger by clicking on the on the toolbar in the Program Editor. Then activate the debugger by clicking on the bug to the left of your code. You can then step through your DATA step, line by line, and see the values of your variables change. You can even set a Watch variable to tell you specifically when the value of that variable changes.

 

 

 

7.     Syntax Help Window

 

 Sometimes you might not remember the exact syntax for a function or a statement, and you need quick help. You can hover over the keyword and the syntax help window will appear.  In addition to the at-a-glance information provided, you can also access product documentation, samples and SAS notes, and papers.

 

Bonus tip: Keyboard shortcuts are available to make it even easier!

 

Search the online syntax help for the selected keyword.

Ctrl+Shift+H

Search SAS Technical Papers for the selected keyword.

Ctrl+Shift+P

Search SAS Product Documentation for the selected keyword.

Ctrl+Shift+D

Search SAS Samples and Notes for the selected keyword.

Ctrl+Shift+N

Open the syntax help for the appropriate argument in a SAS function when the cursor is positioned in the function argument list.

Ctrl+Shift+spacebar

 

 

These are only some of the many options and tips for working in the program editor in SAS Enterprise Guide. In my next article, I'll give you tips for working with logs.  In the meantime, enjoy trying out the new program editor tips! 

Comments

Great tips and videos!

 

And for those that missed Part 1 of the series, check out @KDG's, Quick Tips for SAS Enterprise Guide Users: Customizing General Options

 

The formatting is strange with odd indenting and is often incomplete. 

 

I prefer to use http://poorsql.com/ for formatting code.  Compare the results for yourself.

Version history
Last update:
‎06-13-2019 04:54 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags