Return of the Codes -- SAS', Windows' and Your's

5,425 views
5,317 views

Published on

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.

Published in: Technology, Education
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
5,425
On SlideShare
0
From Embeds
0
Number of Embeds
3,732
Actions
Shares
0
Downloads
45
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Return of the Codes -- SAS', Windows' and Your's

  1. 1. R t Return of the Codes: f th C d SAS ®, Windows’® SAS’® Windows ®, and Your’s Your s Mark Tabladillo Ph.D. MarkTab Consulting Associate Faculty, University of Phoenix Copyright © 2007, SAS Institute Inc. All rights reserved. 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. Microsoft is a registered trademark of Microsoft Corporation in the United States and other countries.
  2. 2. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  3. 3. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  4. 4. Communicate C i t Better! Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  5. 5. Introduction Applications have an ongoing conversation • Users, Databases, Other Applications Return code represents many of these often numeric messages Event messages d E t describe th general ib the l communication category Error messages are a special case Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  6. 6. Purpose Describe how three innovative messaging sources support robust SAS applications development 1. SAS (the programming language) 2. Windows (the operating system) 3. Yours (customized) Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  7. 7. SAS Windows Who’s Talking? WE! (you and me) ( d ) Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  8. 8. SAS 101: Print a Dataset options pagesize=60 linesize=80 pageno=1 nodate; libname mylib 'permanent-data-library'; 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'; run; Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  9. 9. SAS 101: Print a Dataset SAS 201: How do you know it works? options pagesize=60 linesize=80 pageno=1 nodate; libname mylib 'permanent-data-library'; 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'; run; Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  10. 10. SAS 101: Print a Dataset SAS 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'; 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'; run; Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  11. 11. SAS Category One: SAS® C O S S® SAS provides efficient event messaging using seven features: 1. 1 System Options S t O ti 2. Automatic Macro Variables 3. ARM Macros 4. Functions 5. Call MODULE Routine 6. 6 PUT Statement 7. SCL Event Classes Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  12. 12. SAS SAS: S S S System Options O System options are instructions that affect the SAS session Querying system options can be done through dictionary tables Use SCL commands OPTGETC OPTGETN OPTGETC, OPTGETN, OPTSETC, and OPTSETN Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  13. 13. SAS SAS: S S S System Option Examples O DSNFERR – Controls how SAS responds when a SAS dataset is not found ERRORCHECK – controls error handling MPRINT – Displays SAS statements that are generated by macro execution Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  14. 14. SAS SAS: S S Automatic Macro Variables The SAS macro processor creates automatic macro variables Automatic macro variables complement system options by allowing SAS to report current state Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  15. 15. SAS SAS: S S Automatic Macro Variables SYSRC (read and write) – various system- related return codes SYSPROCESSID – the process ID of the current SAS process SYSPROCESSNAME – the process name of the current SAS process Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  16. 16. SAS SAS: S S ARM Macros ARM (Automatic Response Measurement) Macros provide a way to measure the performance of applications as they execute The macros are lightweight and are designed to run outside the DATA step and PROC p statements The ARM API provides an interface to retrieve performance information Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  17. 17. SAS SAS: S S Functions A function performs a computation or system manipulation on arguments and returns a value In addition to base SAS functions, SCL provides other functions which have return codes Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  18. 18. SAS SAS: S S Function Examples SYSRC – returns a system error number SYSGET – returns the value of the specified p operating environment variable SYSTEM – issues an operating system environment command during a SAS session and returns the system return code Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  19. 19. SAS SAS: C S S CALL Module Routine CALL Module “calls the external routine without any return code” CALL Module “calls the external routine without an explicit SAS return code” Allows extended reach in Windows and Unix Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  20. 20. SAS SAS: S S PUT Statement S The PUT statement allows for general reporting to the LOG or any ODS destination Allows for documenting and reporting return codes to users Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  21. 21. SAS SAS: SCL S S SC Event Classes C Events allow for communication among visual and non-visual classes The SCL Exception class provides a framework for throwing exceptions (distinct from regular events) ) Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  22. 22. Windows Category Two: Windows® C ® Windows provides SAS efficient event messaging using four features: 1 SAS S t 1.SAS System O ti Options f Windows for Wi d 2.SAS Automatic Macro Variables for Windows 3.SAS Functions and CALL Routines for Windows 4.Windows System Error Codes Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  23. 23. Windows Windows: S S Features SAS SAS has separate documentation for each operating system SAS running on Windows has extended capabilities for • System options • Automatic macro variables • Functions and CALL routines Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  24. 24. Windows Windows: Windows 32 API S System Error C Codes The CALL module routine can access the Windows 32 API DLLs The full list of Windows error codes can be returned to SAS The gateway can also provide interactive communication with Windows Supported in 64-bit Vista and Server 2008 64 bit Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  25. 25. Yours Category Three: Yours C We can create event messaging systems that emulate what SAS and Windows provide Three distinct outputs 1. Receive no response 2. 2 Receive a response sometimes (incomplete) 3. Always receive a response Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  26. 26. Yours Category Three: Yours Category Description Application Options Similar to SAS system options, application options are variables declared either globally or locally for an application, and allow for return code processing to be controlled from a higher level. The variables could be stored in application datasets, similar to the read-only read only dictionary tables tables. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  27. 27. Yours Category Three: Yours Category Description Application Macro Variables Similar to SAS automatic macro variables, the th application macro variables ( l b l or li ti i bl (global local) provide the ability to keep the state at a specific p p point. Information stored could be character or text (though macro variables always store information as text). Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  28. 28. Yours Category Three: Yours Category Description Application Macros Similar to SAS ARM Macros, the application can hhave it own macros t monitor and its to it d measure performance. These customized macros could extend the capabilities of ARM macros, providing the application with robust reporting on performance. Developing these macros separately from other macros allows them to be used in future applications. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  29. 29. Yours Category Three: Yours Category Description Functions Similar to SAS functions, applications can define d fi methods i SCL Th th d in SCL. These methodsth d can provide a return code, and could extend or incorporate what SAS natively p p y provides for return code processing. Encapsulating these methods individually, or as a group (creating a class or classes using SAS/AF) would allow these methods or classes to be copied into future applications. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  30. 30. Yours Category Three: Yours Category Description CALL Module Similar to calling Windows DLLs, SAS Routine applications running in Windows could call li ti i i Wi d ld ll programmed .NET DLLs. These modules could have return codes and messages helping the application to become more robust. Generically developed DLLs have the advantage of being used across many custom applications. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  31. 31. Yours Category Three: Yours Category Description Reporting Datasets and Forms Instead of simply using the PUT statement to t send variable values t th l d i bl l to the log, an application could store the information in a dataset. Also, the application could have , pp customized forms for reporting errors, including the option to send those reports as an attachment or the body of an e-mail e-mail. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  32. 32. Yours Category Three: Yours Category Description Event Classes Create event classes which capture specific return codes as events. Create customized t d t C t t i d SCL classes based on the SCL exception class; alternatively, use a language which ; y, g g can produce a COM interface to work with SAS to provide advanced error capabilities. Use event classes to communicate across components and applications. Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  33. 33. Advice f Reusable C for Code Use binary codes for success or failure y Consider global enumeration storage to allow for named references to return code conditions Use 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 log log (database or file) Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  34. 34. Conclusion Described how three innovative messaging sources support robust SAS applications development 1. SAS (the programming language) 2. Windows (the operating system) 3. Your’s (customized) Comprehensive return messaging defines robust applications Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  35. 35. Communicate C i t Better! Copyright © 2007, SAS Institute Inc. All rights reserved. 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.
  36. 36. R t Return of the Codes: f th C d SAS ®, Windows’® SAS’® Windows ®, and Your’s Your s Mark Tabladillo Ph.D. MarkTab Consulting Associate Faculty, University of Phoenix Copyright © 2007, SAS Institute Inc. All rights reserved. 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. Microsoft is a registered trademark of Microsoft Corporation in the United States and other countries.

×