Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie,...

9
1 Quick Tips for SAS ® Enterprise Guide ® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS ® Enterprise Guide ® user interface has a different look and feel than Base SAS (Display Manager) which may discourage users at first glance. This paper illustrates an array of quick tips to improve your SAS Enterprise Guide experience. Tips include managing the windows, setting user options, writing quick macros and adding prompts and notes to programs. Several of these quick tips apply to Base SAS as well. INTRODUCTION The initial view of Enterprise Guide (EG) can look complex and daunting to many users. This paper provides some quick shortcuts and tips that I learned when making the transition from Display Manager to Enterprise Guide. First, I give a quick tour the default user environment (windows). This is followed by an array of quick suggestions to improve the user experience. The goal of this paper is to save SAS users time while getting familiar with Enterprise Guide. GETTING FAMILIAR WITH THE ENTERPRISE GUIDE INTERFACE This section is a brief overview on the Enterprise Guide interface. For intermediate EG users familiar with the Enterprise Guide interface, please proceed to the next sections of this paper. At first glance, the Enterprise Guide application looks very menu driven and can be unpleasant to traditional SAS programmers. It took me a while to reconcile the log and output windows. After time, I came to realize that the interface has many more features than the SAS Display Manager. All work done in your EG session is organized in one file called a Project with the file extension “.epg”. A sample project is shown below. All code, data, log and output are contained in the project and represented as Nodes (the icons) shown in the Process Flow window below. The process flow represents your desktop that displays all your work. I find this process flow window useful because projects can be broken into steps. For example, instead of 1000 lines of code in one program that don’t have natural breaks you can have 4 or 5 programs as steps within a process flow. You can always export all code to a single program file by going to File Export Export All Code. The Process Flow and Project Tree windows give programmers an easy view of your entire project. You can also pull existing SAS programs into your project with shortcuts (non-embedded programs) or place the programs into the project (embedded programs). Display 1. SAS ® Enterprise Guide ® Interface

Transcript of Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie,...

Page 1: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

1

Quick Tips for SAS® Enterprise Guide®

R. Scott Leslie, STATisfy Analytics, San Diego, CA

ABSTRACT

The SAS® Enterprise Guide

® user interface has a different look and feel than Base SAS (Display Manager) which

may discourage users at first glance. This paper illustrates an array of quick tips to improve your SAS Enterprise Guide experience. Tips include managing the windows, setting user options, writing quick macros and adding prompts and notes to programs. Several of these quick tips apply to Base SAS as well.

INTRODUCTION

The initial view of Enterprise Guide (EG) can look complex and daunting to many users. This paper provides some quick shortcuts and tips that I learned when making the transition from Display Manager to Enterprise Guide. First, I give a quick tour the default user environment (windows). This is followed by an array of quick suggestions to improve the user experience. The goal of this paper is to save SAS users time while getting familiar with Enterprise Guide.

GETTING FAMILIAR WITH THE ENTERPRISE GUIDE INTERFACE

This section is a brief overview on the Enterprise Guide interface. For intermediate EG users familiar with the Enterprise Guide interface, please proceed to the next sections of this paper.

At first glance, the Enterprise Guide application looks very menu driven and can be unpleasant to traditional SAS programmers. It took me a while to reconcile the log and output windows. After time, I came to realize that the interface has many more features than the SAS Display Manager.

All work done in your EG session is organized in one file called a Project with the file extension “.epg”. A sample project is shown below. All code, data, log and output are contained in the project and represented as Nodes (the icons) shown in the Process Flow window below. The process flow represents your desktop that displays all your

work. I find this process flow window useful because projects can be broken into steps. For example, instead of 1000 lines of code in one program that don’t have natural breaks you can have 4 or 5 programs as steps within a process flow. You can always export all code to a single program file by going to File Export Export All Code. The Process Flow and Project Tree windows give programmers an easy view of your entire project. You can also

pull existing SAS programs into your project with shortcuts (non-embedded programs) or place the programs into the project (embedded programs).

Display 1. SAS® Enterprise Guide

® Interface

Page 2: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

2

CHANGING SAS ENTERPRISE GUIDE SETTINGS

If you would like to change the Enterprise Guide environment such as Project Tree views and outputted results, go to the Tools Options. For instance, you can change the format of your output using the Results Results General

option. You can choose to generate SAS Report, HTML, PDF, RTF, and/or text files. You can also change windows ToolOptionsRestore Window Layout.

Display 2. Changing your Environment with the Options Menu

SAS ENTERPRISE GUIDE VERSIONS

Some users are unaware that EG ships with SAS so purchasing an additional module is not needed. Table 1 lists EG versions with corresponding Base SAS versions. Earlier EG versions can work with recent Base SAS versions and vice versa. The latest EG version as of publication of this version is 7.11 which was released in May 2015. Latest Base SAS version is 9.4 Maintenance Phase 3, or 9.4M3.

Enterprise Guide Version SAS Version

4.2 9.2

4.3 9.2, 9.3

5.1 (Feb-12) 9.2, 9.3, 9.4

6.1 (Jul-13) 9.2, 9.3, 9.4

7.1 (Oct-14) 9.2, 9.3, 9.4

7.11 (May-15) 9.2, 9.3, 9.4

Table 1. SAS Versions

Display 1 shows Enterprise Guide versions by year relative to Base SAS releases. This image was created using code from the SAS blogs site - Chris Hemedinger, blogger name=SAS Dummy, http://blogs.sas.com/content/sasdummy/2013/08/06/eg-versions-through-years/

Page 3: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

3

Display 3. SAS Enterprise Guide Versions

QUICK TIPS

The remainder of this paper describes several functions and tips that I’ve learned from reading documentation during my programming career.

QUICK TIP #1 - CUSTOMIZE YOUR PROCESS FLOW

The process flow represents your desktop that charts all your work. SAS EG automatically arranges the Nodes (icons) in the Process Flow window by default. A user can turn off this default Auto Arrange feature allowing the

user to drag and place Nodes as desired. To change the feature, right-click anywhere in the Process Flow and uncheck Auto Arrange.

Display 4. Disable Auto Arrange Feature

Page 4: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

4

QUICK TIP #2 – KEYBOARD SHORTCUTS

Here are some shortcuts that you may find helpful when coding.

Keystroke Action

Ctrl + / Ctrl + Shift + /

Comment code Uncomment code

Ctrl + G Prompt for a “Go To” line

Ctrl + Shift + U Ctrl + Shift + L

Change case of code in editor Upper case Lower case

Shift + Page Up Shift + Page Down

Page up and mark Page down and mark

Ctrl + I Formats code

Table 2. Keyboard Shortcuts

QUICK TIP #3 – CODE FORMATTER

Programmers have different coding styles and some adhere to coding conventions more than others. The Code Formatter tool formats your code to SAS conventions. Right-click in the Program Editor window and select Format Code or press CTRL + I. Here’s an example.

Before Code Formatter

DATA CARS;

FORMAT MSRP_HIGH 8.;

SET SASHELP.CARS;

IF MSRP >= 39215 THEN MSRP_HIGH=1;

ELSE MSRP_HIGH=0;

LABEL MSRP_HIGH='HIGH-PRICED CAR';

RUN;

After Code Formatter

DATA CARS;

FORMAT MSRP_HIGH 8.;

SET SASHELP.CARS;

IF MSRP >= 39215 THEN

MSRP_HIGH=1;

ELSE MSRP_HIGH=0;

LABEL MSRP_HIGH='HIGH-PRICED CAR';

RUN;

QUICK TIP #4 - ASSIGN AN ABBREVIATION MACRO

You can create abbreviations that write often-used code somewhat like the auto-text feature in Microsoft Word. For example, you can assign a macro so that typing “pp” will insert this code,

proc print data=test (obs=10);

run;

Assigning an Abbreviation Macro can be done from the Program menu, Program Add Abbreviation Macro

QUICK TIP #5 - CHANGE THE REPLACING RESULTS PROMPT WINDOW

When submitting code in EG, a default setting asks if you want to replace results from the last time you submitted code. Users may find this cumbersome because it requires another click when submitting code. You can change

Page 5: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

5

this setting by going to Tools Options Results. Under the Manage Results section there is a drop down

menu where that can change to “Replace without prompting”.

Here is a description of the 3 Replace results options from the SAS documentation:

Do not replace - does not replace the existing results when you rerun a task. A new task item is added to the project tree each time you rerun the task. New task objects are also added to the process flow.

Prompt before replacing - prompts you before your existing results are overwritten by new results when you rerun a task.

Replace without prompting - automatically replaces your existing results when you rerun a task.

Display 5. Replacing Results Feature

QUICK TIP #6 - DATA EXPLORATION FEATURE

The Data Exploration feature, introduced with Version 5.1, allows the user to profile a data set quickly. I find this useful to run descriptive statistics and visualize a data set. It’s somewhat tricky to find and can be resource intensive with large data sets. The Data Exploration feature can be found by going to FILE OPEN DATA EXPLORATION.

Here’s a view of the sashelp.cars data set. Notice the Quick Stats Tab on the right side menu

Page 6: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

6

Display 6. Data Exploration Feature

QUICK TIP #7 - WORKSPACE LAYOUT

I like to code while viewing data sets so I can see variables names and the data structure. In order to do this, I change my workspace from the View menu. Here I stack windows to view an open data set and a program.

View Workspace Layout Stacked

Display 7. Workspace Layout Stacked View

Page 7: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

7

QUICK TIP #8 – CHANGE THE DEFAULT TITLE AND FOOTER

EG populates footer and titles with default text. For instance, the default footer of a graph could look like this,

“Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), NLTIMAP20.))”

You can change the title and footer text from the Tools Options Tasks Tasks General

Display 8. Workspace Layout Stacked View

QUICK TIP #9 - EXCLUDE WRAPPER CODE

By default, EG displays the ODS statements, %LET statements and other code that is automatically generated by SAS in the log file. This option applies to both SAS tasks and SAS program files. If you don’t want to see all this code in the log, uncheck the default setting, “Show generated wrapper code in SAS log”, under Tools Options and Results Results General.

Page 8: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

8

Output 1. Output from a Data Statement

QUICK TIP #10 – ADD NOTES TO YOUR PROGRAM

You can create a note to accompany a project or files in a project. Notes allow you to,

Communicate to other users of same project

Reminders for yourself

Track location of files and data sources

Notes are saved as part of the project file. You can link notes to one or more objects in a process flow. For more information, see Annotating a process flow.

To create notes, go to File New Note

Display 9. Adding Notes to Program

CONCLUSION

SAS Enterprise Guide offers features that can accelerate SAS users’ programming capabilities. Knowledge of several shortcuts can assist users adopting Enterprise Guide.

Page 9: Quick Tips for SAS Enterprise Guide · 1 Quick Tips for SAS® Enterprise Guide® R. Scott Leslie, STATisfy Analytics, San Diego, CA ABSTRACT The SAS® Enterprise Guide® user interface

Quick Tips for SAS® Enterprise Guide®, continued

9

RECOMMENDED READING

SAS documentation http://support.sas.com/documentation/onlinedoc/guide/index.html

Chris Hemedinger’s The SAS Dummy blog. SAS Blogs Home. http://blogs.sas.com/content/sasdummy/

Getting Started with SAS Enterprise Guide – free learning tutorial available at http://support.sas.com/documentation/onlinedoc/guide/tut42/en/menu.htm

Tricia Anderud’s Enterprise Guide page, http://www.bi-notes.com/sas-enterprise-guide/

Tricia Anderud’s Enterprise BI Notes Blog, Data Exploration Feature http://bi-notes.com/2012/06/sas-eg-5-1-data-exploration-feature/

Little SAS Book for Enterprise Guide 4.2 – By Susan J. Slaughter, Lora D. Delwiche, http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=61861

SAS Fact Sheet, Accessed 7/09/15 http://www.sas.com/content/dam/SAS/en_us/doc/factsheet/sas-enterprise-guide-101431.pdf

CONTACT INFORMATION

Your comments and questions are valued and encouraged. Contact the author at:

Name: R. Scott Leslie Enterprise: STATisfy Analytics City, State: San Diego, CA Phone: 949-322-5226 E-mail: [email protected]

Visit my user page on SasCommunity.org, http://www.sascommunity.org/wiki/User:Rsleslie

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are trademarks of their respective companies.