Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Copyright © SAS Inst itute Inc. A l l r ights reserved.
SAS® Enterprise GuideTM:Tips, Tricks, & Considerations for the SAS Programmer
T WinandSolution ArchitectSAS Customer Success Team
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerWhy this presentation?
• Many users stick with what they know • They don’t have time to explore• We (SAS) don’t always advertise all of the enhancements or features
Also…• Much of the information on Enterprise Guide™ is not directly relevant for the SAS
Programmer
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS Programmer
SAS® Enterprise Guide is much more than a point-and-click interface to SAS. This session looks at both new and existing functionality to help both novice as well as the long time programmers.
Copyright © SAS Inst itute Inc. A l l r ights reserved.
SAS® Enterprise Guide™The Swiss Army Knife of SAS
• Offers visualization of what you are doing
• Data access and manipulation
• Analysis
• Descriptive statistics
• Advanced analytics
• Forecasting
• Reporting
• Ad-hoc
• Run programs with updated information
• Stored Processes
• Development environment
• Tasks
• Coding
• Stored process authoring
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerTopics
• Overview Considerations – Gains & Losses
• A Different Paradigm – Projects, Process Flows & Programs *
• The Basics
• Error Handling
• SAS Libraries
• Auto Complete & Syntax Help
• Enhanced Editor Options
• Window Navigation
• SAS Logging
• The Project Log
• Changing Default Behaviors
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerTopics
• Taking Advantage of a Paradigm Shift (part 1)
• Parsing Up the Mega-Program
• Creating An Ordered List
• Linking
• Taking Advantage of a Paradigm Shift (part 2)
• Using a Task to Write Code
• Using Code to Expand a Task
• Using Tasks to Inspect Your Data
• Other Tips & Tricks
• Exporting, Scheduling, & Sharing
• Formatting Code
• Using the Data Step Debugger & Other Development Tools
• Common User Feedback
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Overview ConsiderationsGains & Losses
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerAn Important Note
• Many aspects of programming in Enterprise Guide (EG) are the same as programming in Display Manager(what may be referred to as “PC SAS”)
• But… the architecture is necessarily different resulting in some changes in how the programmer interacts with EG versus Display Manager (DM)
• In a handful of cases, certain DM functionality is not available in EG.
• In the many cases, DM functionality is available in EG through a different means.
• Many features of Enterprise Guide provide enhancements over programming in the DM.
Create a Stored Process from Code with a Prompted Filter
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerWhat is Lost & What is Gained
• What You Lose- Very Quick Program-Submit-Debug Cycles
- Some Features – like interactive logging
• What You Gain- Better organization of data and the programs In Project Explorer and Workspace
- Same Enhanced Editor
- Shared Programs (+ debugger…)
- Run and modify/re-run tasks quickly (e.g. Query Builder, Charting, Descriptive Statistics
- Use tasks as Code Generators
- No need to deal with ODS Output
Create a Stored Process from Code with a Prompted Filter
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerProjects, Process Flow, & Programs
• Open Enterprise Guide
• Create a New Project or Open an Existing Project
• Create a New Process Flow
• Create New Program (Embedded) or open an Existing Program
Create a Stored Process from Code with a Prompted Filter
Copyright © SAS Inst itute Inc. A l l r ights reserved.
The BasicsError Handling, SAS Libraries, Editor Options & Windows
Copyright © SAS Inst itute Inc. A l l r ights reserved.
The BasicsProgramming Errors
• Programming Errors
• What happens
• Debugging help
Create a Stored Process from Code with a Prompted Filter
Copyright © SAS Inst itute Inc. A l l r ights reserved.
The Basics
• Libname in program
• Assign Project Library Task
• Autoexec Process FlowCre
SAS Libraries
Copyright © SAS Inst itute Inc. A l l r ights reserved.
The BasicsSAS Libraries
• Libname in program
• Assign Project Library Task
• Autoexec Process Flow
• Tools>Options>SAS Programs
• Libraries can be set up by your SAS Administrator
Create a Stored Process from Code with a Prompted Filter
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Auto-Complete & Syntax AssistanceThe Basics
Copyright © SAS Inst itute Inc. A l l r ights reserved.
How to TuneThe Basics
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Enhanced Editor Options
The Basics
Program > Editor Options
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Enhanced Editor Keys
The Basics
Program > Enhanced Editor Keys
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Moving Between & Around WindowsThe Basics
• Tabs• Program > Split
Create a Stored Process from Code with a Prompted Filter
Copyright © SAS Inst itute Inc. A l l r ights reserved.
The BasicsAnother Option – Maximize Workspace
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Another Option – Split WorkspaceThe Basics
Copyright © SAS Inst itute Inc. A l l r ights reserved.
SAS LoggingChallenges & Options
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Challenges & TipsSAS Logging
Challenge for PC SAS Programmers
• In EG, when we submit a program or selection, the log is created
• When we submit the program or selected code again, the log is overwritten with a new log
Tips & Tricks that Might Help
• Use the Project log – it keeps a rolling log for the project until it is cleared
• Maximize Workspace and change the Workspace Layout to Stacked or Side by Side
• Change the default behavior upon program execution
Copyright © SAS Inst itute Inc. A l l r ights reserved.
SAS LoggingProject Log
Copyright © SAS Inst itute Inc. A l l r ights reserved.
SAS LoggingChange Default Behaviors
Go to Tools > Options to change default behavior of windows on program execution
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Projects & Process FlowsUtilizing a Paradigm Shift (part 1)
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm Shift
Challenge for PC SAS Programmers
• Instead of one “mega-program”, break it up into a process flow
• With manageable program blocks
• Each with its own log & results
• Rename Code Nodes to enhance
“Mega-Program” versus Process Flow
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm Shift“Mega-Program” versus Process Flow
Challenge for PC SAS Programmers
• Instead of one “mega-program”, break it up into a process flow
• With manageable program blocks
• Each with its own log & results
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftOrdering Program Execution
Order in Which Programs Execute
• Left to Right
• Top to Bottom
• As directed through the Ordered List Capability
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftCreating & Running An Ordered List
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftLinking Data to Program
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Projects & Process FlowsUtilizing a Paradigm Shift (part 2)
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftUsing a Task to Write Code – Query Example
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftUsing a Task to Write Code – Charting Example
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftUsing a Task to Write Code
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Using Code to Expand a Task
EXPLODE = “USA”;
Utilizing a Paradigm Shift
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Using Tasks to Inspect Your DataUtilizing a Paradigm Shift
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftUsing Descriptive Statistics Tasks
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Utilizing a Paradigm ShiftUsing Graph Tasks
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksAnd Tools That Might Help
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksExporting Process Flow or Project Code
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksScheduling
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksSharing Your Projects
You can share your projects with others by using relative pathnames:
File > Project Properties
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksFormatting Code
You may have inherited a program that looks like this…
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksFormatting Code
Right click on the Workspace & Select Format Code
And Your Code is Formatted
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Using The Data Step DebuggerOther Tips & Tricks
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksUsing the Debugger
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Other Tips & TricksOther Developer Tools
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Prompts & Stored ProcessesSomething to Consider
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Prompts & Stored ProcessesA Quick View
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Prompts & Stored ProcessesHow to Create
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Prompts & Stored ProcessesRunning & Results
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Prompts & Stored ProcessesRunning as an Excel Report
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Common User Feedback
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackLogging
Log does not automatically append after each code submission, it clears
Oftentimes, I like to submit my SAS code in pieces as opposed to running the entire code at once; however, I’d still like for the log to accumulate instead of overwriting with each new submitted statement.
I would like to clear my SAS log and output window, occasionally, at my discretion.
Response : • One current approach uses the Project Log• Another current approach is to break up your large program into smaller programming
steps in a process flow. Each step has its own log and results.• EG 8.1 will offer improvements here.
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User Feedback# of Observations
Hard to see the number of observations in SAS datasets.
Two Options
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackProjects & Process Flows
TS Response : • This is the current paradigm of SAS Enterprise Guide.• EG 8.1 will have an option that gives a better PC SAS look and feel with program
window, log, and results all opened at once and un-docked if needed to move to whatever position you like.
The project flow perspective is not something I am interested in at all, yet it seems to be the main focus of the interface. For example, when I open up EG, instead of bringing me to a new SAS program window, it brings me to the Process Flow grid. Is there anything we can do to suppress project flow features?
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackChanging Default Behaviors on Submission
Response : • This can be done by clicking Tools > Options > Results General & unclick “Automatically
open data or results when generated” and also set the “Maximum number of output data sets to add to the project” to 0. (Supplied By User; confirmed by TS)
• There are options for each user to set up his/her EG environment to his/her liking. I am not sure I would set “Maximum number of output data sets to add to the project” to 0. Try different options and see which is better for you.
I do not want EG to open every SAS dataset that gets created in my code, but I do want to be able to open manually and explore any SAS dataset that I wish to browse.
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackViewing Multiple Datasets
Response : • For current EG, you can use View > Workspace Layout > Side by Side, then, select the
"star" to "activate" the panel you want to open the data into.....not clean but it works.• EG 8.1 will have a much better interface for viewing multiple objects at once.
Sometimes I like to browse and have open multiple SAS datasets and look at
them side-by-side. By default, EG only allows you to open/view one SAS dataset
at a time.
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackKeyboard Shortcuts
I can’t find any keyboard shortcuts to toggle between open SAS programs in my session.
Response : • For programmers, I would simply open multiple EG sessions.• EG 8.1 will make it simple to open multiple SAS program windows in a single EG
project.
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackImporting Excel Files
Response : • Tools > Options > Data > General• Change Valid variable names under “Naming Options” from “Extended variable
names (ANY)” to “Basic variable names (V7)” regardless if they use the Import Data task or code.
When importing datasets (such as from Excel) which use a header row for field names, sometimes the header rows are not compliant with SAS variable names (i.e. starting with a number, having spaces in its name, etc.). EG, by default, allows these field names to be non-SAS compliant which is problematic.
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackXcmd
Response : • This option is available in SAS Enterprise Guide.• By default it is turned off at the Administration Level, but the SAS Administrator can
switch this option on.• Then you can run x commands from your SAS program in EG
I cannot run Xcmd (x command) in EG like I was able to do in PC SAS
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User FeedbackSupport for DDE
Response : • Can run as long as SAS software and DDE “partner” run on same Windows PC• This does not work in a centralized SAS Environment• BLOG: Why your DDE programs don’t work anymore
Support for DDE (Microsoft Dynamic Data Exchange)
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User Feedback Other
Accessing Data that is not on the SAS Server?
Response• i.e. how to access data from a network share. So our path
to out network share is \\sashq\root\....
Copyright © SAS Inst itute Inc. A l l r ights reserved.
User Feedback Other
Is there a way to make the project log be the default log?
Response• The answer is no – not at this time
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Closing InformationWhat’s Coming, Documentation, Papers & more…
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerWhat’s Coming
Preview of What’s Coming in SAS Enterprise Guide and SAS Studio
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerDocumentation
http://support.sas.com/software/products/enterprise-guide/index.html#s1=3
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS ProgrammerSAS Papers on Programming in SAS Enterprise Guide
• Becoming a Better Programmer with SAS® Enterprise Guide® 4.3
• 184-2008: Writing Code in SAS® Enterprise Guide®
• 019-30: Boost Your Programming Productivity with SAS® Enterprise ...
• Enterprise Guide®: Tips for Programmers
• 137-2010: SAS® Programmer's Paradise: New Goodies in SAS ...
• Becoming a Better Programmer with SAS® Enterprise Guide® 4.3
• 138-2013: SAS® Enterprise Guide® 5.1: A Powerful Environment for ...
• Programming with SAS® Enterprise Guide
• A SAS Programmer's Guide to the SAS Enterprise Guide
• 137-2010: SAS® Programmer's Paradise: New Goodies in SAS ...
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Tips, Tricks, & Considerations for the SAS Programmer
• SAS Enterprise Guide Debugger:
• https://blogs.sas.com/content/sasdummy/2016/11/30/data-step-debugger-sas-eg/
• https://support.sas.com/resources/papers/proceedings17/SAS0447-2017.pdf
• https://video.sas.com/sasgf17/detail/videos/tech-talks/video/5383617444001/sas-tech-talk:-data-step-debugger-in-sas-enterprise-guide?autoStart=true&page=1
• Xcmd in SAS Enterprise Guide:
• https://blogs.sas.com/content/sasdummy/2012/08/31/the-case-for-xcmd-privileges-in-sas-enterprise-guide/
sas.com
Copyright © SAS Inst itute Inc. A l l r ights reserved.
Thank you for your time and for using SAS!