sas tricks and techniques from the snug committee · sas tricks and techniques from the snug...

Post on 03-Jul-2019

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

SAS Tricks and TechniquesFrom the SNUG Committee

Bhupendra PantUniversity 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

5

Category Language elements Description

Controlling Program Execution

(G)O Starts or resumes execution of the DATA step.

JUMP Restarts execution of a suspended program.

STEP (default: Enter Key)

Executes statements one at a time in the active program.

Controlling the Windows HELP Displays information about debugger commands.

SWAP Switches control between the SOURCE window and the LOG window.

Manipulating DATA Step Variables

CALCULATE Evaluates a debugger expression and displays the result.

(DES)CRIBE Displays the attributes of one or more variables.

(EX)AMINE Displays the value of one or more variables.

SET Assigns a new value to a specified variable.

Data Step Debugger Commands by Category (cont)

6

Category Language elements Description

Manipulating Debugging Requests

(B)REAK Suspends program execution at an executable statement.

(D)ELETE Deletes breakpoints or the watch status of variables in the DATA step.

LIST Displays all occurrences of the item that is listed in the argument.

TRACE Controls whether the debugger displays a continuous record of the DATA step execution.

(W)ATCH 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

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 thisIn 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.html ∙      

• 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?

top related