SAS Log Summarizer Finding What s Most Important in the SAS Log

Similar documents
The 'SKIP' Statement

A Macro to replace PROC REPORT!?

Application of Modular Programming in Clinical Trial Environment Mirjana Stojanovic, CALGB - Statistical Center, DUMC, Durham, NC

Cutting the SAS LOG down to size Malachy J. Foley, University of North Carolina at Chapel Hill, NC

KEYWORDS Metadata, macro language, CALL EXECUTE, %NRSTR, %TSLIT

PharmaSUG Paper PO12

TLF Management Tools: SAS programs to help in managing large number of TLFs. Eduard Joseph Siquioco, PPD, Manila, Philippines

Automated Checking Of Multiple Files Kathyayini Tappeta, Percept Pharma Services, Bridgewater, NJ

ODS/RTF Pagination Revisit

Please don't Merge without By!!

Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio

Cleaning up your SAS log: Note Messages

Prove QC Quality Create SAS Datasets from RTF Files Honghua Chen, OCKHAM, Cary, NC

PharmaSUG Paper TT11

Beginner Beware: Hidden Hazards in SAS Coding

Gary L. Katsanis, Blue Cross and Blue Shield of the Rochester Area, Rochester, NY

Paper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ

title1 "Visits at &string1"; proc print data=hospitalvisits; where sitecode="&string1";

Reading and Writing RTF Documents as Data: Automatic Completion of CONSORT Flow Diagrams

Quality Control of Clinical Data Listings with Proc Compare

3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200;

Interleaving a Dataset with Itself: How and Why

Tales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board

A Few Quick and Efficient Ways to Compare Data

PROC CATALOG, the Wish Book SAS Procedure Louise Hadden, Abt Associates Inc., Cambridge, MA

CC13 An Automatic Process to Compare Files. Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ

Using SAS Macros to Extract P-values from PROC FREQ

footnote1 height=8pt j=l "(Rev. &sysdate)" j=c "{\b\ Page}{\field{\*\fldinst {\b\i PAGE}}}";

Using SAS Enterprise Guide to Coax Your Excel Data In To SAS

Not Just Merge - Complex Derivation Made Easy by Hash Object

A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY

Application Interface for executing a batch of SAS Programs and Checking Logs Sneha Sarmukadam, inventiv Health Clinical, Pune, India

Reading a Column into a Row to Count N-levels, Calculate Cardinality Ratio and Create Frequency and Summary Output In One Step

Regaining Some Control Over ODS RTF Pagination When Using Proc Report Gary E. Moore, Moore Computing Services, Inc., Little Rock, Arkansas

TLFs: Replaying Rather than Appending William Coar, Axio Research, Seattle, WA

Step through Your DATA Step: Introducing the DATA Step Debugger in SAS Enterprise Guide

If You Need These OBS and These VARS, Then Drop IF, and Keep WHERE Jay Iyengar, Data Systems Consultants LLC

Debugging 101 Peter Knapp U.S. Department of Commerce

Run your reports through that last loop to standardize the presentation attributes

INTRODUCTION THE FILENAME STATEMENT CAPTURING THE PROGRAM CODE

A Way to Work with Invoice Files in SAS

Handling Numeric Representation SAS Errors Caused by Simple Floating-Point Arithmetic Computation Fuad J. Foty, U.S. Census Bureau, Washington, DC

Anatomy of a Merge Gone Wrong James Lew, Compu-Stat Consulting, Scarborough, ON, Canada Joshua Horstman, Nested Loop Consulting, Indianapolis, IN, USA

Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA

Posters. Workarounds for SASWare Ballot Items Jack Hamilton, First Health, West Sacramento, California USA. Paper

PharmaSUG China 2018 Paper AD-62

Common Sense Validation Using SAS

Statistics, Data Analysis & Econometrics

Essentials of PDV: Directing the Aim to Understanding the DATA Step! Arthur Xuejun Li, City of Hope National Medical Center, Duarte, CA

Automated Macros to Extract Data from the National (Nationwide) Inpatient Sample (NIS)

Creating and Executing Stored Compiled DATA Step Programs

One SAS To Rule Them All

ABC Macro and Performance Chart with Benchmarks Annotation

Developing SAS Studio Repositories

Clinical Data Visualization using TIBCO Spotfire and SAS

Tales from the Help Desk 6: Solutions to Common SAS Tasks

Combining TLFs into a Single File Deliverable William Coar, Axio Research, Seattle, WA

Importing CSV Data to All Character Variables Arthur L. Carpenter California Occidental Consultants, Anchorage, AK

PDF Multi-Level Bookmarks via SAS

A Macro that can Search and Replace String in your SAS Programs

Be Your Own Task Master - Adding Custom Tasks to EG Peter Eberhardt, Fernwood Consulting Group Inc. Toronto, ON

SESUG Paper RIV An Obvious Yet Helpful Guide to Developing Recurring Reports in SAS. Rachel Straney, University of Central Florida

What Do You Mean My CSV Doesn t Match My SAS Dataset?

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA

Remember to always check your simple SAS function code! Yingqiu Yvette Liu, Merck & Co. Inc., North Wales, PA

2. Don t forget semicolons and RUN statements The two most common programming errors.

A Macro to Keep Titles and Footnotes in One Place

Can you decipher the code? If you can, maybe you can break it. Jay Iyengar, Data Systems Consultants LLC, Oak Brook, IL

Using MACRO and SAS/GRAPH to Efficiently Assess Distributions. Paul Walker, Capital One

Paper S Data Presentation 101: An Analyst s Perspective

PharmaSUG Paper AD09

Data Edit-checks Integration using ODS Tagset Niraj J. Pandya, Element Technologies Inc., NJ Vinodh Paida, Impressive Systems Inc.

How to use UNIX commands in SAS code to read SAS logs

Indenting with Style

Hidden in plain sight: my top ten underpublicized enhancements in SAS Versions 9.2 and 9.3

ABSTRACT MORE THAN SYNTAX ORGANIZE YOUR WORK THE SAS ENTERPRISE GUIDE PROJECT. Paper 50-30

Amie Bissonett, inventiv Health Clinical, Minneapolis, MN

PharmaSUG China Paper 059

A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN

Sign of the Times: Using SAS to Produce Conference Signage Daniel K. Downing, Caremark, Scottsdale, Ariz.

CMISS the SAS Function You May Have Been MISSING Mira Shapiro, Analytic Designers LLC, Bethesda, MD

Compute; Your Future with Proc Report

ABSTRACT INTRODUCTION SIMPLE COMPOSITE VARIABLE REVIEW SESUG Paper IT-06

Square Peg, Square Hole Getting Tables to Fit on Slides in the ODS Destination for PowerPoint

Pros and Cons of Interactive SAS Mode vs. Batch Mode Irina Walsh, ClinOps, LLC, San Francisco, CA

3N Validation to Validate PROC COMPARE Output

BI-09 Using Enterprise Guide Effectively Tom Miron, Systems Seminar Consultants, Madison, WI

Using PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA

100 THE NUANCES OF COMBINING MULTIPLE HOSPITAL DATA

Dictionary.coumns is your friend while appending or moving data

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

PharmaSUG Paper TT03. Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California

Paper TT17 An Animated Guide : Speed Merges with Key Merging and the _IORC_ Variable Russ Lavery Contractor for Numeric resources, Inc.

ODS LAYOUT is Like an Onion

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

ODS DOCUMENT, a practical example. Ruurd Bennink, OCS Consulting B.V., s-hertogenbosch, the Netherlands

Taming a Spreadsheet Importation Monster

Program Validation: Logging the Log

PROC DOC III: Self-generating Codebooks Using SAS

SAS Survey Report Macro for Creating User-Friendly Descriptive Summaries

Transcription:

Paper CC-037 SAS Log Summarizer Finding What s Most Important in the SAS Log Milorad Stojanovic RTI International Education Surveys Division RTP, North Carolina ABSTRACT Validity of SAS programs is an important task. Lots of information about the execution of SAS programs can be found in SAS Log file. Carefully examination of the SAS log is a mandatory task, but it can be cumbersome and tedious for very large logs. Log Summarizer is a tool designed to reduce the burden of this review. It can be used to extract the most important information (ERRORs, WARNINGs, and specific NOTEs), while preserving section indicators, statement sequence, original line numbers and message text. Log Summarizer s output is in RTF format and will provide programmer and/or QA analyst with a condensed version of the information they are most interested in reviewing. KEYWORDS: SAS LOG, ERROR, WARNING, NOTE INTRODUCTION To do programming jobs correctly we should check the results of our programs. Author points to the papers by Rick Mitchell (1) and Howard and Gayari (2) as ones everybody should take time to read. Both papers give excellent guidelines how to validate your results on the more broader basis than only checking SAS LOG. As users of SAS, analyst, programmers, statisticians and others are keenly interested in the successful operation of SAS programs, and are generally satisfied to have their programs execute successfully (resulting in new files, reports or both) while paying no attention to the SAS LOG. Other users, however, will check the program LOG for ERRORs only. And still others will check all messages in the SAS LOG. The most thorough and complete check would include checking of results of each step, but it is often a cumbersome and lengthy process. For example, newly created data sets which end up with 0 observations and N variables could indicate possible errors in data processing, which could be the first sign that something went wrong. In the papers already presented at various SAS User Group (SUG) meeting (see references) authors used a more or less generalized approach to analyzing SAS LOGs and to extract important information from their perspective. Mainly they were dealing with ERROR, WARNING and selected NOTE messages. This paper takes the review a step further, by recommending additional checking for missing BY statements, checking for data set(s) with 0 observations, and checking for messages that another process was locking the data set. DESCRIPTION OF PROGRAM The goal was to prepare a condensed report structured in several sections with the hierarchy of messages from the most severe to the simply informative. SAS LOGs were treated as any other text file, with a log file line size of 200 characters. The SAS logs were searched for three keywords: ERROR, WARNING, and NOTE. NOTE messages were differentiated, as some of them are purely informational with no significant value for finding mistakes in program, whereas others could often (but not always) point to some incorrect behavior of the program during the execution phase. To make intervention in the program code as small as possible, a %INCLUDE statement was used to isolate specific NOTE messages. In this way, maintenance of the program was much easier. Users are advised to add or remove NOTEs messages and to choose an appropriate location for report as well as for the input SAS LOG. It is important to note that it could be a highly dangerous mistake to exclude a BY statement in MERGE. Although the program will seemingly execute successfully, the results could include some bad merging of input data sets. Moreover SAS would not give any ERROR or WARNING message (if you don t have any other mistakes in said code), but would only yield three naïve NOTE messages such as the following: 1

NOTE: There were 3 observations read from the data set WORK.ONE. NOTE: There were 3 observations read from the data set WORK.TWO. NOTE: The data set WORK.THREE has 3 observations and 3 variables. These seemingly innocuous notes hide a potential disaster. The output will include a new data set in the output, but merging is now highly problematic. The most important thing to note is that this is not VISIBLE at all. Consider the following: Data set ONE Data set TWO No BY statement With BY statement Obs a b Obs a c Obs a b c Obs a b c 1 1 15 1 1 115 1 1 15 115 1 1 15 115 2 2 25 2 2 225 2 2 25 225 2 2 25 225 3 4 45 3 3 335 3 3 45 335 3 3. 335 4 4 45. PROGRAM CODE %let saslog_location = C:\SESUG08\TESTLOG.log; %let saslog_notes = C:\SESUG08\NOTE_messages.txt ; %let report_location = C:\SESUG08 ; %macro SASLOG_Summarizer(saslog_location=, saslog_notes=, report_location=) ; filename infl "&saslog_location." ; options ls=80 ps=50 nodate nonumber ; proc format ; value Typefm 1 = 'ERROR' 2 = 'WARNING' 3 = 'Spec. NOTEs' 4 = 'NOTE' ; data mistakes(keep=type txt line_counter) ; retain line_counter 0 ; length txt $ 190 ; infile infl lrecl=200 pad ; input @1 intext $200. ; line_counter + 1 ; if index(intext, 'ERROR:')>0 then do ; Type = 1 ; pos = index(intext, '2E0D'X) ; txt = substr(intext, 8, pos - 8) ; else if index(intext, 'WARNING:')>0 then do ; Type = 2 ; txt = substr(intext, 10) ; else if index(intext, 'NOTE:')>0 then do ; if index(intext, 'The data set')>0 and index(intext, 'has 0 observations')>0 then do ; Type = 3 ; txt = substr(intext, 6) ; if index(intext, 'NOTE:')>0 then do ; %include "&saslog_notes." ; 2

Type = 4 ; txt = substr(intext, 7) ; * Additional step for checking of missing BY statements in MERGE. ; data mistakes1(keep=type txt line1) ; retain line_counter Merge_flag Data_flag Proc_flag RUN_flag Merge_loc Data_loc Proc_loc Run_loc BY_flag 0; length txt $ 190 ; infile infl lrecl=200 pad ; input @1 intext $200. ; intext = upcase(intext) ; line_counter + 1 ; if index(intext, 'NOTE:')=0 and index(intext, 'ERROR:')=0 and index(intext, 'WARNING:')=0 then do ; if index(intext, ' MERGE ')>0 and index(intext, '*')=0 then do ; Type = 3 ; merge_loc= line_counter ; merge_flag = 1 ; Data_loc=0; Proc_loc=0; Run_loc=0 ; Proc_flag = 0 ; data_flag = 0 ; run_flag = 0 ; by_flag = 0 ; if merge_flag = 1 then do ; if index(intext, ' BY ')>0 then BY_flag = 1 ; if index(intext, ' PROC ')>0 then do ; Proc_flag = 1 ; Proc_loc = line_counter ; if index(intext, ' DATA ')>0 then do ; data_flag = 1 ; Data_loc = line_counter ; if index(intext, ' RUN ;')>0 then do ; run_flag = 1 ; Run_loc = line_counter ; if BY_flag=0 and (Data_flag=1 or Run_Flag=1 or Proc_Flag=1) and (0<=(Line_counter - merge_loc)<=6) then do ; type = 3 ; txt = 'No BY statement for preceding MERGE statement' ; line1 = MERGE_loc ; merge_flag=0 ; Proc_flag = 0 ; data_flag = 0 ; run_flag = 0 ; by_flag = 0 ; data_loc = 0 ; proc_loc = 0 ; merge_loc = 0 ; run_loc = 0 ; proc sort data=mistakes ; by type line_counter ; data mistakes ; set mistakes mistakes1(rename=(line1=line_counter)) ; by type line_counter ; 3

ods rtf file="&report_location\saslog_summarizer.rtf" style=banker ; proc report data=mistakes nowd split='~' ; title J=C "Report from SASLOG Summarizer for:" ; title2 J=C "&saslog_location."; column type line_counter txt ; define type / group order=internal f=typefm. 'Type' ; define line_counter / display f=6. 'Line # in~sas LOG' ; define txt / display width=80 /*f=$90.*/ flow 'Original SAS log message' ; ods rtf close ; %mend SASLOG_Summarizer; %SASLOG_Summarizer(saslog_location=&saslog_location., saslog_notes=&saslog_notes., report_location=&report_location.) Content of include file could be same like in this file or with different content. if index(intext, 'Invalid') > 0 or index(intext, 'W.D format') > 0 or index(intext, 'is uninitialized') > 0 or index(intext, 'repeats of BY values') > 0 or index(intext, 'Mathematical operations could not') > 0 or index(intext, 'Missing values were') > 0 or index(intext, 'Division by zero') > 0 or index(intext, 'MERGE statement') > 0 or index(intext, 'Character values have') > 0 or index(intext, 'values have been converted') > 0 or index(intext, 'Interactivity disabled with') > 0 or index(intext, 'No observation') > 0 then do ; Program execution with input of over 17K+ lines (TESTLOG.log) was below 1 (one) second on author s PC. With separation of LOG keyword messages into separate file (NOTE_Messages.txt) program / macro gets enough of flexibility and could be tailored to the need of each user. EXAMPLE OF REPORT Report from SASLOG Summarizer for: C:\SESUG08\TESTLOG.log Type ERROR WARNING Line # in SAS LOG Original SAS log message 17369 File NEW.TEST1.DATA does not exist 17372 No data set open to look up variables 17404 Errors printed on pages 304,305 2368 Multiple lengths were specified for the BY variable PR by input data sets. This may cause unexpected results. 16277 The variable RACE in the DROP, KEEP, or RENAME list has never been referenced. 16278 The variable SEX in the DROP, KEEP, or RENAME list has never been referenced. 17374 No data sets qualify for WHERE processing. 4

Line # in Type SAS LOG Original SAS log message Spec. NOTEs 2921 No BY statement for preceding MERGE statement 3789 The data set WORK.TEST2 has 0 observations and 5 variables. 4943 No BY statement for preceding MERGE statement NOTE 929 Invalid argument to function INPUT at line 3263 column 25. 988 Missing values were generated as a result of performing an operation on missing values. 991 Mathematical operations could not be performed at the following places. The results of the operations have been set to 1517 Numeric values have been converted to character values at the places given by: (Line):(Column). 1519 Character values have been converted to numeric values at the places given by: (Line):(Column). 4280 No observations in data set WORK.TEST3. CONCLUSION With investing of relatively moderate efforts it was possible to get useful reports which directs SAS users to the most important messages in the SAS LOG and provided an additional tool for QA of SAS programs. Absolute position of message in SAS LOG gives quick access to the point of possible mistake. ACKNOWLEDGEMENTS Author would like to thank James Isaacs and Peter Einaudi from Education Studies Division (RTI) for all their help, comments, and support in producing this paper. REFERENCES 1. Mitchell, Rick M., Finding Your Mistakes Before They Find You: A Quality Approach For SAS Programmers http://www.nesug.info/proceedings/nesug06/as/as04.pdf, NESUG 2006 2. Howard Neil, Gayari Michelle, Validation, SAS, and the Systems Development Life Cycle: An Oxymoron? http://www.lexjansen.com/pharmasug/2000/dmandvis/dm09.pdf, Pharmasug 2000 3. Truong Sy, Making Code Review Painless, http://www.meta-x.com/wuss12_making_code_review_pain.pdf, WUSS 12 4. Smoak Carey G, A Utility Program for Checking SAS Log Files, http://www2.sas.com/proceedings/sugi27/p096-27.pdf SUGI 27 5. Gregg Keith M. Gershteyn Yefim, Checking and Tracking SASâ Programs Using SASâ Software, http://www.units.muohio.edu/doc/sassystem/sugi25/24/appdevel/p28-24.pdf SUGI 25 6. Augustine Aaron, Dutta Prasenjit, You ve Got E-Mail: Automatic Log Checking Via E-mail Notification http://www2.sas.com/proceedings/sugi31/128-31.pdf SUGI 31 7. Li Tianshu, A Macro to Report Problematic SAS Log Messages in a Production Environment http://www.nesug.org/proceedings/nesug01/cc/cc4008.pdf NESUG 2001 8. Markovitz Heidi, SAS Completion Codes to Make Complex Programs Run Smoothly http://analytics.ncsu.edu/sesug/2002/cc07.pdf SESUG 2002 9. Humphreys Suzanne, %LOGCHECK: a Convenient Tool for Checking Multiple Log Files http://www.lexjansen.com/pharmasug/2008/cc/cc02.pdf Pharmasug 2008 5

10. Foley Malachy J., Cutting the SAS LOG down to size, http://analytics.ncsu.edu/sesug/2004/sy05- Foley.pdf SESUG 2004 11. Mason Philip, SASTip77 - Automatic checking of the LOG, http://www.listserv.uga.edu/cgi-bin/wa?a2=ind0310d&l=sas-l&p=16971 12. Mark Terjeson,Log file reading program, http://www.listserv.uga.edu/cgi-bin/wa?a2=ind0411e&l=sas-l&p=16645 13. Fehd Ronald, Tip: macro LOGSAVE v1, http://www.listserv.uga.edu/cgi-bin/wa?a2=ind0110d&l=sas-l&f=&s=&p=8887 14. Sherman Paul, Intelligent SAS Log Manager, http://analytics.ncsu.edu/sesug/2007/ad15.pdf SESUG 2007 DISCLAIMER All opinions and suggestions stated in the paper on how to check and validate SAS LOGs do not necessarily reflect the opinions and suggestions of RTI International. Use any of commercial products mentioned in references for checking SAS LOG is the responsibility of the individual user. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Milorad Stojanovic Education Surveys Division RTI International 3040 Cornwallis Rd RTP, NC, 27909 Work Phone : (919) 541-7376 E-mail: milorad@rti.org TRADEMARK INFORMATION SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are trademarks of their respective companies. 6