Fall 2017 Questions and Answers (Q&A)

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Chapter 9: Introducing Macro Variables 1 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Backup and Recovery Part 1.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
5/30/2010 SAS Macro Language Group 6 Pradnya Nimkar, Li Lin, Linsong Zhang & Loc Tran.
Macro Overview Mihaela Simion. Macro Facility Overview Definition : The SAS Macro Facility is a tool within base SAS software that contains the essential.
June 12, 2009 Toronto Area SAS Society 1 What’s new in BASE SAS 9.2 Checkpoint/Restart Rupinder Dhillon Dhillon Consulting Inc.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
BMTRY 789 Lecture 10: SAS MACRO Facility Annie N. Simpson, MSc.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Creative Create Lists Elizabeth B. Thomsen Member Services Manager
Immigration – Common Errors and How To Conduct An Internal I-9 Audit
Do-more Technical Training
Temporary vs. Permanent SAS Data Sets
VBA - Excel VBA is Visual Basic for Applications
Greg Steffens Noumena Solutions
Using ODS Excel Migrating from DDE to ODS
Data-Basics Training & Support
Chapter 6: Modifying and Combining Data Sets
Compiler Construction (CS-636)
Programming Standards and Practices
(or SASopardy, if you will)
OASUS Spring or Fall YYYY
Chapter 2: Getting Data into SAS
LESSON 20.
State Report Processing
Two “identical” programs
SAS Programming Introduction to SAS.
Microsoft Access Illustrated
OASUS Spring or Fall YYYY
ECONOMETRICS ii – spring 2018
Translators & Facilities of Languages
Chapter 18: Modifying SAS Data Sets and Tracking Changes
3 Macro Storage.
Chapter 1: Introduction to SAS
Instructor: Raul Cruz-Cano
OASUS Spring or Fall YYYY Lihsin Hwang Statistics Canada
Make your SAS programs ready for any language
James Blankenship March , 2018
Chapter 7: Macros in SAS Macros provide for more flexible programming in SAS Macros make SAS more “object-oriented”, like R Not a strong suit of text ©
Topics Introduction to File Input and Output
Chapter 7 Files and Exceptions
Modify the Macro Put legend of the figure Change the figure screen size Format the rate with 2 decimals Refine title of table and figure by the.
An Introduction to Structured Program Design in COBOL
Introduction to SAS A SAS program is a list of SAS statements executed in order Every SAS statement ends with a semicolon! SAS statements can be in caps.
Defining and Calling a Macro
Checkpoint Restart Demo (Using Labels)
Checkpoint Restart Demo (Using Steps)
Lisa Mendez, PhD & Andrew Kuligowski
Never Cut and Paste Again
Automate Repetitive Programming Tasks: Effective SAS® Code Generators
A Useful Footnote Martha Cox Population Health Research Unit Community Health & Epidemiology Dalhousie University Good morning. We've all had this happen:
Stata Basic Course Lab 2.
Purpose Real life scenario: I have a set of reports to refresh every month but data is only available at any day during Day 3 – 5 at beginning of each.
3 Views.
EECE.2160 ECE Application Programming
Data Manipulation (with SQL)
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Topics Introduction to File Input and Output
Frank DiIorio CodeCrafters, Inc. Philadelphia PA
Writing Robust SAS Macros
Presentation transcript:

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

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

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

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

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

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

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

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

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

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

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

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

Line and Column References in Macros

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

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

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

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=78.3342 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=78.3342 =98.2851 Use PUTLOG statement putlog vara =; vara=78.3342 All name - value pairs put _ALL_; vara=78.3342 varb =98.2851 _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

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

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

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

OASUS Spring or Fall YYYY Questions / Comments Thursday, November 15, 2018 Yves DeGuire System Engineering Division Statistics Canada (613) 790-6165 Yves.DeGuire@canada.ca First & last name Company name

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