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

22
SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant University of Western Sydney College

Upload: voanh

Post on 03-Jul-2019

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

SAS Tricks and TechniquesFrom the SNUG Committee

Bhupendra PantUniversity of Western Sydney College

Page 2: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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

Page 3: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

Data Step Debugger

Page 4: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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

Page 5: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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.

Page 6: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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

Page 7: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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

Page 8: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

Screen shot

8

Page 9: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

If you have access to SAS DMS, learn the Data Step Debugger!

9

Page 10: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

Recovering your SAS code from EG

Page 11: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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?

Page 12: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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. 

Page 13: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

Creating documented dataset attributes

Page 14: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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

Page 15: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

You could try thisIn the data grid view click on the properties button

Page 16: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

• Select the columns tab and click on copy to clipboard

Page 17: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

• Paste into excel

Page 18: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

SAS Resources & Links on Enterprise Guide

Page 19: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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 

Page 20: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

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 ∙        

Page 21: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

SAS Webinar Getting Started with SAS Enterprise Guide:http://www.sas.com/reg/web/corp/2208268

Page 22: SAS Tricks and Techniques From the SNUG Committee · SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant ... • The DSD is a port of the old SAS Component Language (SCL)

Questions?