Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2017 Questions and Answers (Q&A)

Similar presentations


Presentation on theme: "Fall 2017 Questions and Answers (Q&A)"— Presentation transcript:

1 Fall 2017 Questions and Answers (Q&A)
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Fall 2017 Questions and Answers (Q&A) Yves DeGuire Statistics Canada First & last name Company name

2 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Question #1 How Can I Restore my SAS Environment after a Crash or On Demand? After a crash: Use the Checkpoint/Restart facility On-Demand: Use the PRESENV facility First & last name Company name

3 The Checkpoint/Restart Facility
OASUS Spring or Fall YYYY Thursday, November 15, 2018 The Checkpoint/Restart Facility The Checkpoint/restart facility allows you to resubmit batch SAS programs that did not complete. 2 modes: Checkpoint Mode: SAS records info about the DATA and PROC steps in a Checkpoint library. Restart Mode: SAS reads the checkpoint library to determine which steps completed successfully. The program resumes at the step that didn’t complete. First & last name Company name

4 Setting Up Your Program
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Setting Up Your Program Add the statement CHECKPOINT EXECUTE_ALWAYS immediately before a step that you want to ALWAYS re-run. Add a LIBNAME statement that defines the checkpoint-restart library Add labels if label sections will be used for Checkpoint/Restart First & last name Company name

5 What about the Work Library?
OASUS Spring or Fall YYYY Thursday, November 15, 2018 What about the Work Library? Must be preserved if the program does not complete with the following options: NOWORKTERM saves the Work library when SAS ends. NOWORKINIT does not initialize the Work library when SAS starts. CHKPTCLEAN specifies whether to erase files in the Work library and delete the Work library if the batch program runs successfully. First & last name Company name

6 Enable Checkpoint/Restart
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Enable Checkpoint/Restart Options for DATA and PROC steps: STEPCHKPT enables checkpoint mode STEPRESTART enables restart mode STEPCHKPTLIB identifies a user-specified checkpoint-restart library Options for labeled sections: LABELCHKPT enables checkpoint mode LABELRESTART enables restart mode LABELCHKPTLIB identifies a user-specified checkpoint-restart library First & last name Company name

7 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Demos Checkpoint/Restart for DATA and PROC steps Checkpoint/Restart for labeled sections First & last name Company name

8 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 The PRESENV Facility Introduced as part of SAS 9.4 Gives the user the ability to save most global options (including titles and footnotes), macros, macro variables, formats, and data between SAS sessions The facility requires that: the PRESENV option be turned on to start saving the environment PROC PRESENV be called in order to store the saved environment and the temp data First & last name Company name

9 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 The PRESENV Option This OPTION saves the following items: Global SAS statements (for example, the FILENAME, LIBNAME, TITLE, and FOOTNOTE statements) Compiled macros in the SAS Work library Temporary formats in the SAS Work library Option settings in your session First & last name Company name

10 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 PROC PRESENV PROC PRESENV PERMDIR=OUTDATA SASCODE=OUTCODE; PERMDIR= specifies a libref where all of the Work data sets, catalogs, and macros are written. SASCODE= specifies a fileref where the SAS program that contains all of the code that is necessary to restore the environment will be stored. First & last name Company name

11 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Demo PRESENV Demo First & last name Company name

12 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Question #2 When I get an error in code generated by a macro, is there a way that I can get a line number that points directly to the location of the error? Difficult because: Line and column numbers in macro code refers to blocks and character offset!!! First & last name Company name

13 Line and Column References in Macros

14 Demacrofied your Code with the MPRINT option
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Demacrofied your Code with the MPRINT option The MPRINT option will output the code generated by a macro to the log. If a fileref called MPRINT is also defined along with the MFILE option, the generated code will also be written out to a file which can be run on its own! filename mprint 'c:\temp\debug.sas'; /* Need to empty the file because mprint uses mod */ data _null_; file mprint; run; options mprint mfile; First & last name Company name

15 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Demo MPRINT Demo First & last name Company name

16 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Question #3 The EG Debugger is really nice. But if we have to make do without it, can you give some tricks to help us debug our programs? ‘Good old’ debugging techniques often rely on the PUT statement. And it is more powerful that you may think!!! First & last name Company name

17 The PUT Statement on Steroids!
OASUS Spring or Fall YYYY Thursday, November 15, 2018 The PUT Statement on Steroids! Tip Statement Results in the log Name/value pair put vara=; vara= Values of arrays put (x [*]) (=); x1=1 x2=4 x3=9 x4=16 x5=25 Name/value pair with a format put ( vara ) (=6.2); vara=78.33 Name/value pair on separate line put (vara varb ) (=/); vara= = Use PUTLOG statement putlog vara =; vara= All name - value pairs put _ALL_; vara= varb = _ERROR_=0 _N_=1 Name/value pair of a macro variable %put &= SYSDATE ; SYSDATE=23NOV17 All name /value pairs of macros variables %put _USER_; GLOBAL MACVAR 98 %put _ALL_; GLOBAL …. AUTOMATIC …. First & last name Company name

18 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 My Last Q&A  Number of Questions Year Spring Fall 2005 4 6 2006 9 ? 2007 5 2008 14 2009 11 2010 12 2011 8 2012 7 2013 10 2014 2015 2016 2017 3 Total 71+ 69+ Over 140 questions answered! First & last name Company name

19 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 My Top 10 Q&A What When Why 1 Hide passwords in your Programs Spring 2005 Must know 2 Minimize space used by a SAS dataset Spring 2007 Must know 3 Scheduling with EG Fall 2008 Useful 4 Maintain multiple versions of your dataset Spring 2009 Useful 5 Replace missing values with PROC STDSIZE Fall 2011 Useful 6 DATA step vs PROC SQL Spring 2012 Must know 7 PROC Document Spring 2013 Useful Last begin with our first step 8 How to handle very large numbers Fall 2015 Cool!!! 9 Multi - threading with PROC DS2 Fall 2016 Useful 10 Call R from SAS Spring 2017 Useful /Must know First & last name Company name

20 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 Famous Last Word! JUST ANOTHER TOOL in the TOOLBOX! You only need to provide basic PivotTables and the users will quickly learn to exploit them on their own. First & last name Company name

21 OASUS Spring or Fall YYYY
Questions / Comments Thursday, November 15, 2018 Yves DeGuire System Engineering Division Statistics Canada (613) First & last name Company name

22 OASUS Spring or Fall YYYY
Thursday, November 15, 2018 References Dhillon, Rupinder. (2009) What’s new in BASE SAS 9.2: Checkpoint/Restart Fredlund, Keith., Wai, Thinzar. (2016) Painless Extraction: Options and Macros with PROC PRESENV Gilsen, Bruce. (2014) Debugging SAS ® code in a macro Horwitz, Lisa. (2017) A Long-Time SAS® Programmer Learns New Tricks Russel, Kevin., Tyndall, Russ.(2010) SAS® System Options: The True Heroes of Macro Debugging Sherman, Paul D. () SAS/MACRO® NOTES: Lines and Columns in the Log Squillace , Jan. (2013) Flexibility by Design: A Look at New and Updated System Options in SAS® 9.4 Wicklin, Rick. (2017) PUT it there! Six tips for using PUT and %PUT statements in SAS5By on The DO Loop January 16, 2017 First & last name Company name


Download ppt "Fall 2017 Questions and Answers (Q&A)"

Similar presentations


Ads by Google