SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant University of Western Sydney College
SAS Tricks and Techniques 1.Data Set Debugger in DMS 2.Recovering your SAS code from EG 3.Creating documented dataset attributes 4. SAS Resources & Links on Enterprise Guide 2
Data Step Debugger
Data Step Debugger Who has never used the Data Step Debugger? The DSD was first introduced in SAS 6.11. And the interface looks like it! The DSD is a port of the old SAS Component Language (SCL) debugger to the SAS Data Step. However klunky it looks, the DSD is an excellent learning tool to learn the details of the SAS Data Step, as well as solve logic and programming errors in your complex data steps. Unfortunately, the DSD is not available from Enterprise Guide. Documentation: http://support.sas.com/documentation/cdl/en/lebaseutilref/63492/html/ default/viewer.htm#n06w89msxn3za7n10g5sx25pa0j0.htm 4
Data Step Debugger Commands by Category Category Language elements Description Controlling Program Execution (G)O JUMP STEP (default: Enter Key) Starts or resumes execution of the DATA step. Restarts execution of a suspended program. Executes statements one at a time in the active program. Controlling the Windows HELP Displays information about debugger commands. Manipulating DATA Step Variables SWAP CALCULATE (DES)CRIBE (EX)AMINE SET Switches control between the SOURCE window and the LOG window. Evaluates a debugger expression and displays the result. Displays the attributes of one or more variables. Displays the value of one or more variables. Assigns a new value to a specified variable. 5
Data Step Debugger Commands by Category (cont) Category Language elements Description Manipulating Debugging Requests (B)REAK (D)ELETE LIST TRACE (W)ATCH Suspends program execution at an executable statement. Deletes breakpoints or the watch status of variables in the DATA step. Displays all occurrences of the item that is listed in the argument. Controls whether the debugger displays a continuous record of the DATA step execution. Suspends execution when the value of a specified variable changes. Tailoring the Debugger ENTER Assigns one or more debugger commands to the ENTER key. Terminating the Debugger (Q)UIT Quits or Terminates the Debuger 6
Example Invocation Note: There are two bugs in this example data class/debug; do until (eof); if _n_=1 then putlog "Starting the data step..."; set sashelp.class end=eof; m+ifn(sex="m",0,1); if sex="f" then f+1; end; putlog (m f) (=); run; 7
Screen shot 8
If you have access to SAS DMS, learn the Data Step Debugger! 9
Recovering your SAS code from EG
Broken EG Project? Ever had a time when your EG project wont open because it has corrupted or is too big to load? Felt like you have lost all that code you worked on? Did you know you can get the code back?
Here s How. Changer the file extension to.zip In this case I have several sub folders, so I Iooked for the most recent update Open it and there is your SAS code.
Creating documented dataset attributes
Proc contents is a great way of displaying the attributes of a dataset, but is doesn t translate well to distribute to team members. How about getting it to an Excel friendly format? You could use proc contents data = <infile> out = <outfile> then export to the resultant dataset to excel But how about:
You could try this In the data grid view click on the properties button
Select the columns tab and click on copy to clipboard
Paste into excel
SAS Resources & Links on Enterprise Guide
SAS Resources SAS Enterprise Guide SAS Enterprise Guide Overview: http://www.sas.com/technologies/bi/query_reporting/guide/index.html Product Documentation (including what s new across the versions): http://support.sas.com/documentation/onlinedoc/guide/index.html SAS Enterprise Guide Interactive Tour: http://www.sas.com/technologies/bi/query_reporting/guide/tour/itour_flash.ht ml YouTube video from SAS channel Using the Editor in EG for writing Programs New Features: http://www.youtube.com/watch?v=awbn7lqbmrm GOOD one similar to the workshops Various YouTube SAS channel Enterprise Guide videos: http://www.youtube.com/user/sassoftware/videos?query=enterprise+guide SAS Enterprise Guide Technical Papers: http://support.sas.com/resources/papers/tnote/tnote_enterpriseguide.html
List of Webinars SAS Webinar Getting Started with SAS Enterprise Guide: http://www.sas.com/reg/web/corp/2208268 SAS Webinar New Goodies for the SAS Programmer in SAS Enterprise Guide 4.3 (older version but a lot of new features that are still new since EG4.1): http://www.sas.com/reg/web/corp/1259797 SAS Webinar SAS Enterprise Guide for the Programmer: What's in It for Me?: http://www.sas.com/reg/gen/corp/858824 SAS Webinar Making SAS Enterprise Guide the Center of Your Business: http://www.sas.com/reg/web/corp/956991 SAS Webinar Introduction to Custom Tasks in SAS Enterprise Guide: http://www.sas.com/reg/web/corp/2246736
SAS Webinar Getting Started with SAS Enterprise Guide: http://www.sas.com/reg/web/corp/2208268
Questions?