Robust applications engage in the give-and-take discussion between commands and return codes. This presentation encourages applications developers to implement comprehensive return code processing. This paper presents three distinct categories. First, we consider return codes from SAS®. Second, we consider return codes from the Windows® (as an example operating system). Third, we discuss development principles for proactively writing your own return messages. The examples draw from SAS/AF® and Windows®, and affect all SAS applications development (including robust SAS Macro development). This paper introduces the rich conversation an application can and should have with its environment. Special attention focuses on error messages and recovering gracefully from unexpected or unintentional results.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
R t f th C d R t f th C d Return of the Codes: SAS’® Windows’® and Your’sReturn of the Codes: SAS’® Windows’® and Your’sSAS ®, Windows ®, and Your sSAS ®, Windows ®, and Your s
Mark Tabladillo Ph.D.MarkTab ConsultingMark Tabladillo Ph.D.MarkTab Consulting
SAS 101: Print a DatasetSAS 201: How do you know it works?SAS 301: What could go wrong?options pagesize=60 linesize=80 pageno=1 nodate;libname mylib 'permanent-data-library';
SAS 301: What could go wrong?
libname mylib permanent data library ;data mylib.internationaltours;
infile 'input-file';input Country $ Nights AirCost LandCost Vendor $;p y $ g $;
proc print data = mylib.internationaltours;title 'Data Set MYLIB.INTERNATIONALTOURS';
SAS provides efficient event messaging using seven features:
1 S t O ti1. System Options2. Automatic Macro Variables3. ARM Macros4. Functions5. Call MODULE Routine6 PUT Statement6. PUT Statement7. SCL Event Classes
ARM (Automatic Response Measurement) Macros provide a way to measure the performance of applications as they executeperformance of applications as they execute
The macros are lightweight and are designed to run outside the DATA step and PROC pstatements
The ARM API provides an interface to retrieve performance informationperformance information
SYSGET – returns the value of the specified poperating environment variable
SYSTEM – issues an operating system environment command during a SAS sessionenvironment command during a SAS session and returns the system return code
Windows provides SAS efficient event messaging using four features:1 SAS S t O ti f Wi d1.SAS System Options for Windows2.SAS Automatic Macro Variables for Windows3.SAS Functions and CALL Routines for Windows4.Windows System Error Codes
We can create event messaging systems that emulate what SAS and Windows provide
Three distinct outputs1. Receive no response2 Receive a response sometimes (incomplete)2. Receive a response sometimes (incomplete)3. Always receive a response
YoursYoursCategory Three: YoursCategory DescriptionCategory DescriptionApplication Macro Variables Similar to SAS automatic macro variables,
th li ti i bl ( l b lthe application macro variables (global or local) provide the ability to keep the state at a specific point. Information stored could be p p
character or text (though macro variables always store information as text).
YoursYoursCategory Three: YoursCategory DescriptionCategory DescriptionFunctions Similar to SAS functions, applications can
d fi th d i SCL Th th ddefine methods in SCL. These methods can provide a return code, and could extend or incorporate what SAS natively provides p y pfor return code processing. Encapsulating these methods individually, or as a group
(creating a class or classes using SAS/AF)(creating a class or classes using SAS/AF) would allow these methods or classes to be
YoursYoursCategory Three: YoursCategory DescriptionCategory DescriptionEvent Classes Create event classes which capture specific
t d t C t t i dreturn codes as events. Create customized SCL classes based on the SCL exception class; alternatively, use a language which ; y, g gcan produce a COM interface to work with
SAS to provide advanced error capabilities. Use event classes to communicate acrossUse event classes to communicate across
f CAdvice for Reusable CodeUse binary codes for success or failurey
Consider global enumeration storage to allow for named references to return code conditions
Use simple, reusable names for macros, functions, and classesUse simple, reusable names for macros, functions, and classes
Code for the complete set of possible conditions, not only the ones proven through experience
Optionally implement reporting to the SAS log or to an external event logOptionally implement reporting to the SAS log, or to an external event log (database or file)
R t f th C d R t f th C d Return of the Codes: SAS’® Windows’® and Your’sReturn of the Codes: SAS’® Windows’® and Your’sSAS ®, Windows ®, and Your sSAS ®, Windows ®, and Your s
Mark Tabladillo Ph.D.MarkTab ConsultingMark Tabladillo Ph.D.MarkTab Consulting