Be a More Productive Cross-Platform SAS Programmer Using Enterprise Guide Alex Tsui Independent Consultant Business Strategy, Analytics, Software Development ACT Consulting, LLC Introduction As a consultant with a mixed background in business analytics, software product management, and software development, I pay attention to both marketing materials and technical details of software products. The marketing materials provide a high level view of what the product is designed for - the what, and the technical details are - the how. Enterprise Guide (EG), in marketing terms, is positioned mostly as a self-service environment for analysts and statisticians. A SAS programmer s interpretation to this would be not a tool for me. Nonetheless, its modern, Microsoft Visual Studio like user interface eventually attracted me to try it out, of course as a programming tool. I found it is a better SAS programming environment than the very popular PC version Display Manager (DM). All the better things in EG comes in little packages. A bit here, a bit there, they add up to enhance the quality and productivity of your SAS programming work. It is hard to discuss them all here. You have to play with it, and find out its advantages and disadvantages yourselves. In this paper, I will point out a few things that I like about EG especially in cross-platform environments. Note: This paper compares EG with DM for base SAS programming. The use of EG in SAS BI environment is excluded. Skip the drags-and-drops YOU are in control. Because EG is mostly positioned for drag-and-drop based data analysis, it presents users with the Process Flow sheet when first opened. However, this is not the part of EG I want to use when I program since I have always believed that, in life, tools should serve people, not vice versa. So I IGNORE this sheet and go right to the menu to open (figure 1) a new plain code sheet. Now we are ready to code. In fact, now we are in the Enhanced Editor the same one as in DM. 1
Figure 1 Redcross save lives. Here, we intentionally created a short piece of code with an error in both EG (figure 2) and DM (figure 3). Imagine the erroneous code is buried in a program with thousands of Figure 2 lines of code and output even more in the log file. In DM, one will have to search the log file for error messages. And it s easy not to spot it. But in EG, the error will trigger two red crosses in the User Interface (UI) to alert you that at least one error has occurred. You cannot miss them! Since our programming work is often so critical to mankind, these little red crosses can save lives! 2
Figure 3 Copy & Paste It s Windows, after all! SAS users often need to move data to and from Microsoft Office applications, especially Excel. In DM, one can open a dataset, but you cannot copy (ctrl-c) the data out directly to Microsoft Office applications. In EG, you can. And it s as easy as copying cells in Excel. My wish list to SAS Institute: include column headers, i.e. variable names in the copy/paste. By the way, another feature in EG comes handy. In DM, view in Excel removes the leading zeros for character column with all numbers. This is often not desired. You will not have such a problem when exporting to Excel from EG. Click, click, and click less is more. In DM, like many SAS programmers, I like to go to the log window right-click mouse, go to Edit, then select Clear_All (Figure 4) before I run a selected section of (or the entire) code, so I won t mix the log output of this run with the log messages of other runs before. In EG, by default, it is set automatically (configurable) to clear the log for this run a little representative productivity feature in EG. FTP: It s recession. Auction it on ebay. EG is designed for a world where data and programs on different computers can all be available at your finger tips to solve the problem on hand. Such product design addresses the reality of today s business IT environment. As a personal anecdotal experience, it has always been UNIX Figure 4 3
SAS plus PC SAS with the clients I served in the last few years. This is different than SAS/Connect people often use with DM. SAS/ Connect enables you to run SAS code on remote systems. In EG you can do this too. However, you have more. You have the entire remote file system available to you in the server sheet. You can easily copy/paste files from one directory to another, from one computer to another, all in the same user friendly manner of the copy/paste of the Windows environment. No more needs for the old cross-platform workhouse ftp. You love rsubmit, you got it. A lot of SAS programmers love to use rsubmit when developing solutions that are cross platform in nature. You can still do this in EG. Make sure SAS Connect spawner is running on the remote host (by contacting your SAS admin). Add a signon at the beginning of your code: Signon remote=host. port user=users1 pass=mypassword; If you don t like to put your password in plain text (and in most cases you shouldn t) in the code, there are a number of things you can do 1) Use an encoded password. a. run Proc pwencode in =mypassword; run; b. find the encoded version of the password in the log file c. change signon to Signon remote=host. port user=users1 pass= encoded password ; 2) Use a prompt parameter. a. Create a prompt parameter: Right click anywhere in the code window -> Properties. In the Properties for Coder dialog, select Parameters -> Parameter Manager. In Parameter Manager, create a macro variable, I named it mypasswd, and select the Prompt for value option. Make sure to add the parameter to the project. b. Add the parameter to the code: 4
Signon remote=host. port user=users1 pass=&mypasswd; When the above line is executed, EG invokes a dialog box for you to enter your password. Project Neat organizer and click reducer. Computer science 101 modularization. If you program SAS like you would program in any modern programming languages, like C (not so modern), C++, Java, C#, etc, your code might be stored in many files. The project feature in EG can be handy to organize these files. Further, it memorizes the file locations you brought into the project in your previous session when you re-open the project in EG. You can open any of these file with one single click no need to navigate down the file directory paths. Less click, more productivity. Conclusion The key benefits any software development tools aim for are productivity and ease of producing quality results. The PC version of Display Manager with Enhanced Editor was a big improvement to help SAS programmers along these dimensions. Enterprise Guide, even from the pure SAS programming perspective, made further advances. If you do a lot of SAS programming, I encourage you to try EG out. You might just be converted. Acknowledgement I would like to use this opportunity to express my appreciation to my current and past consulting clients for providing me opportunities to serve them on business and technical issues. I also want to acknowledge Louise Hadden s contribution of the humorous Auction on ebay and Murali Talanayar s on-going support and review of my initial draft. References 1. SAS Enterprise Guide Help. 2. Chris Hemedinger, Boost Your Programming Productivity with SAS Enterprise Guide, SUGI 30 3. John Hennessey, SAS Enterprise Guide and SAS/CONNECT Software Peaceful Co-Existence Using SAS Code, SUGI 31 Contact Information Your insights, comments, and questions are appreciated. Contact the author at Alex Tsui ACT Consulting, LLC Morris Plains, NJ 07950 Web Site: www.actconsultingllc.com Email: alex.tsui@actconsultingllc.com 5
Phone: 650-814-3475 DISCLAIMER 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 registered trademarks or trademarks of their respective companies. 6