SUGI 29 Coders' Corner



Similar documents
Automating SAS Macros: Run SAS Code when the Data is Available and a Target Date Reached.

SUGI 29 Applications Development

Overview. NT Event Log. CHAPTER 8 Enhancements for SAS Users under Windows NT

Counting the Ways to Count in SAS. Imelda C. Go, South Carolina Department of Education, Columbia, SC

SDTM, ADaM and define.xml with OpenCDISC Matt Becker, PharmaNet/i3, Cary, NC

Mathematical Harmonies Mark Petersen

Supporting a Global SAS Programming Envronment? Real World Applications in an Outsourcing Model

What's New in SAS Data Management

Guide to Operating SAS IT Resource Management 3.5 without a Middle Tier

Essential Project Management Reports in Clinical Development Nalin Tikoo, BioMarin Pharmaceutical Inc., Novato, CA

SAS BI Dashboard 4.4. User's Guide Second Edition. SAS Documentation

Simple Rules to Remember When Working with Indexes Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California

College SAS Tools. Hope Opportunity Jobs

You have got SASMAIL!

ProjectTrackIt: Automate your project using SAS

While You Were Sleeping - Scheduling SAS Jobs to Run Automatically Faron Kincheloe, Baylor University, Waco, TX

Paper PO03. A Case of Online Data Processing and Statistical Analysis via SAS/IntrNet. Sijian Zhang University of Alabama at Birmingham

The Chord Book - for 3 string guitar

Lost in Space? Methodology for a Guided Drill-Through Analysis Out of the Wormhole

SAS, Excel, and the Intranet

Using Pharmacovigilance Reporting System to Generate Ad-hoc Reports

SAS/Data Integration Studio Creating and Using A Generated Transformation Jeff Dyson, Financial Risk Group, Cary, NC

Interfacing SAS Software, Excel, and the Intranet without SAS/Intrnet TM Software or SAS Software for the Personal Computer

Definitive Piano Improvisation Course

Introduction to REDCap for Clinical Data Collection Shannon M. Morrison, M.S. Quantitative Health Sciences Cleveland Clinic Foundation, Cleveland, OH

Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX

IT Service Level Management 2.1 User s Guide SAS

Optimizing System Performance by Monitoring UNIX Server with SAS

JobSuite Sample Workflow and Template

Paper Robert Bonham, Gregory A. Smith, SAS Institute Inc., Cary NC

Statistics and Analysis. Quality Control: How to Analyze and Verify Financial Data

SAS PROGRAM EFFICIENCY FOR BEGINNERS. Bruce Gilsen, Federal Reserve Board

One problem > Multiple solutions; various ways of removing duplicates from dataset using SAS Jaya Dhillon, Louisiana State University

PharmaSUG Paper QT26

Be a More Productive Cross-Platform SAS Programmer Using Enterprise Guide

OS/2: TELNET Access Method

CDW DATA QUALITY INITIATIVE

SAS Add in to MS Office A Tutorial Angela Hall, Zencos Consulting, Cary, NC

Session Attribution in SAS Web Analytics

Page 1 of 36. Companion Workbook leadworship.com

Chapter 32 Histograms and Bar Charts. Chapter Table of Contents VARIABLES METHOD OUTPUT REFERENCES...474

An macro: Exploring metadata EG and user credentials in Linux to automate notifications Jason Baucom, Ateb Inc.

Analyzing the Server Log

Chapter 2 How To Cheat A Barre Chord

Salary. Cumulative Frequency

SUGI 29 Coders' Corner

One Report, Many Languages: Using SAS Visual Analytics to Localize Your Reports

PharmaSUG Paper AD11

SAS. Cloud. Account Administrator s Guide. SAS Documentation

9.1 SAS/ACCESS. Interface to SAP BW. User s Guide

An Introduction to SAS/SHARE, By Example

A Microsoft Access Based System, Using SAS as a Background Number Cruncher David Kiasi, Applications Alternatives, Upper Marlboro, MD

Importing Excel Files Into SAS Using DDE Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

SAS 9.3 Foundation for Microsoft Windows

Determine What SAS Version and Components Are Available

A: zero everywhere. B: positive everywhere. C: negative everywhere. D: depends on position.

Lever Harp Tunings & Major Keys

3 More on Accumulation and Discount Functions

Data Mining: An Overview of Methods and Technologies for Increasing Profits in Direct Marketing. C. Olivia Rud, VP, Fleet Bank

Chapter 27 Using Predictor Variables. Chapter Table of Contents

SAS Credit Scoring for Banking 4.3

How to Use SDTM Definition and ADaM Specifications Documents. to Facilitate SAS Programming

Transferring vs. Transporting Between SAS Operating Environments Mimi Lou, Medical College of Georgia, Augusta, GA

Top Ten SAS DBMS Performance Boosters for 2009 Howard Plemmons, SAS Institute Inc., Cary, NC

Chapter 25 Specifying Forecasting Models

Technical Paper. Defining an ODBC Library in SAS 9.2 Management Console Using Microsoft Windows NT Authentication

FIRST STEP - ADDITIONS TO THE CONFIGURATIONS FILE (CONFIG FILE) SECOND STEP Creating the to send

Table of Contents Cicero, Inc. All rights protected and reserved.

Beginner Guitar Level I

QualityView - a program database and validation documentation tool

SAS System and SAS Program Validation Techniques Sy Truong, Meta-Xceed, Inc., San Jose, CA

PROC LOGISTIC: Traps for the unwary Peter L. Flom, Independent statistical consultant, New York, NY

How To Write A Clinical Trial In Sas

Desktop Activity Intelligence

Paper Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA

SAS 9.4 Logging. Configuration and Programming Reference Second Edition. SAS Documentation

EcOS (Economic Outlook Suite)

DBF Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 7

PharmaSUG Paper DG06

GUITAR THEORY REVOLUTION. Part 1: How To Learn All The Notes On The Guitar Fretboard


SAS 9.3 Logging: Configuration and Programming Reference

SAS Comments How Straightforward Are They? Jacksen Lou, Merck & Co.,, Blue Bell, PA 19422

ing Automated Notification of Errors in a Batch SAS Program Julie Kilburn, City of Hope, Duarte, CA Rebecca Ottesen, City of Hope, Duarte, CA

OnDemand for Academics

SLIM Estimate and Microsoft Project Best Practices

USE CDISC SDTM AS A DATA MIDDLE-TIER TO STREAMLINE YOUR SAS INFRASTRUCTURE

Modeling Lifetime Value in the Insurance Industry

9.2 User s Guide SAS/STAT. Introduction. (Book Excerpt) SAS Documentation

Transcription:

Paper 048-29 ABSTRACT Making Music in SAS : Using Sound to Alert Users of Errors and Data Discrepancies David Fielding, AAI Development Service, Mississauga, ON Did you know you could have SAS play music? This paper explores the SOUND and SLEEP routines. Let SAS alert you of an error in your program, a specific type of data, or just add some excitement in your life. INTRODUCTION In today s fast pace environment it is important to be alerted to problems immediately. We will look at how we can use sound in our programs to alert us during runtime. We will start with an introduction into the physics of music and how this relates to the CALL SOUND routine. Then we will look at CALL SLEEP. Then we will look at a macro for translating sheet music into SAS code using CALL SOUND and CALL SLEEP. MUSIC BACKGROUND Sound waves each have a specific frequency; it is the frequency that distinguishes the notes we hear. The frequency is measured in hertz which measures cycles per second. The chart below shows how each note relates to the frequency. Table 1. Notes and related frequencies. (Wenzel) Notes Frequency (octaves) A 55.00 110.00 220.00 440.00 880.00 A#/Bb 58.27 116.54 233.08 466.16 932.32 B 61.74 123.48 246.96 493.92 987.84 C 65.41 130.82 261.64 523.28 1046.56 C#/Db 69.30 138.60 277.20 554.40 1108.80 D 73.42 146.84 293.68 587.36 1174.72 D#/Eb 77.78 155.56 311.12 622.24 1244.48 E 82.41 164.82 329.64 659.28 1318.56 F 87.31 174.62 349.24 698.48 1396.96 F#/Gb 92.50 185.00 370.00 740.00 1480.00 G 98.00 196.00 392.00 784.00 1568.00 G#/Ab 103.83 207.66 415.32 830.64 1661.28 Frequency (hertz) 3500 3000 2500 2000 1500 1000 500 0 A D G C F A# D# G# C# F# B E A D G Notes Figure 1. Higher notes increase exponentially. 1

CALL SOUND CALL SOUND(frequency,duration) where the frequency specifies the sound frequency in terms of cycles per second and the duration specifies the sound duration in milliseconds. (SAS Help) APPLICATION The following sample dataset is used for the CALL SOUND examples. There are 5 observations for the variable n (0,3,5,.,6) which will be used in the examples. data sample; input n; cards; 0 3 5. 6 ; EXAMPLE 1 If you batch submit programs on a regular basis and would like to be notified of an error in a data step before checking the log. Add the statement if _ERROR_=1 and use CALL SOUND. Of course a dataset that produces a lot of errors may not go over well with nearby co-workers. In the example when calculating b=2/n, when n is 0 the error Division by zero detected occurs and _ERROR_ becomes 1. When _error_ is set to 1, the if statement then produces the sound and the user is immediately aware of a problem in the dataset. The notes E (659), D (587) and C (523) are played for 200 milliseconds. data example1; set sample; b=2/n; if _error_=1 then do; call sound(659,200); call sound(587,200); call sound(523,200); EXAMPLE 2 In the pharmaceutical industry, medications and adverse events are coded to standard dictionaries for analysis. To prevent sending a client a term that hasn t been coded, just add code to notify of missing codes. In the example, values 0,3,5 are coded but. and 6 remain uncoded. When the program is run the sound notifies the user immediately of uncoded terms as they are read in. The notes C (523), D (587) and E (659) are played for 200 milliseconds. data example2; set sample; length code $5.; if n in (0,3,5) then code="coded"; if code="" then do; call sound(440,200); call sound(523,200); call sound(659,200); Sound can be used to notify the user of specific data that may require further action. Another use is to communicate to yourself in a program. If you ve changed a program and wanted to make sure you validated it before running it next time, set up a call sound that can be turned off when validation is complete. Of course you can always just add a song to any routinely run program just to add some excitement in your life or others. CALL SLEEP CALL SLEEP(n,unit) where n specifies the number of units of time that you want to suspend the execution of a DATA step. Specifies the unit of time, as a power of 10, which is applied to n. The default is 1 in a Windows or a PC environment. In other environments the default is.001. Where 1 corresponds to a second. (SAS Help) 2

EXAMPLE data _null_; call sleep(30,1); NOTE: DATA statement used: real time 30.03 seconds DF3 MACRO The DF3 macro allows you to play a song by sending the musical note, its octave and how long to play it. The notes are A-G as on any piano keyboard. To indicate a flat add b or a sharp add # (Middle C is octave 3). To play a rest use R with the length. The length is how long to hold the note, in 4/4 timing 1 would be a quarter note, 2 a half note and 4 a whole note. The duration of the call sound is supposed to be in milliseconds but the length of the sound is not consistent across PC s. Adjust the macro variable pc as a multiplier to the length of a note. If your PC plays the sample song very slowly decrease this number. %let pc=1.25; %macro df3(note,octave,length); select(&note.); when('a') call sound(55*(2**&octave.),&length.*160*&pc.); when('a#') call sound(58*(2**&octave.),&length.*160*&pc.); when('bb') call sound(58*(2**&octave.),&length.*160*&pc.); when('b') call sound(62*(2**&octave.),&length.*160*&pc.); when('c') call sound(65*(2**&octave.),&length.*160*&pc.); when('c#') call sound(69*(2**&octave.),&length.*160*&pc.); when('db') call sound(69*(2**&octave.),&length.*160*&pc.); when('d') call sound(73.5*(2**&octave.),&length.*160*&pc.); when('d#') call sound(73.5*(2**&octave.),&length.*160*&pc.); when('eb') call sound(78*(2**&octave.),&length.*160*&pc.); when('e') call sound(82*(2**&octave.),&length.*160*&pc.); when('f') call sound(87*(2**&octave.),&length.*160*&pc.); when('f#') call sound(92.5*(2**&octave.),&length.*160*&pc.); when('gb') call sound(92.5*(2**&octave.),&length.*160*&pc.); when('g') call sound(98*(2**&octave.),&length.*160*&pc.); when('g#') call sound(104*(2**&octave.),&length.*160*&pc.); when('ab') call sound(104*(2**&octave.),&length.*160*&pc.); when('r') call sleep((&length./3)*&pc.,1); otherwise; %m /* SAMPLE */ /* Old MacDonald Had a Farm */ data _null_; do i=1 to 2; %df3('g',2,1); 3

%df3('c',3,2); if i=1 then do; %df3('r',1,2); %df3('c',3,2); %df3('g',2,1); %df3('c',3,3); CONCLUSION It is always important to review your log after running a SAS program, by adding CALL SOUND you will be notified of data discrepancies and errors during runtime. The DF3 macro can be used to translate sheet music into SAS music and let you entertain your friends. REFERENCES Wenzel, Charles. Musical Notes, Techlib.com Reference Materials. http://www.techlib.com/reference/musical_note_frequencies.htm (January 14, 2004). SAS Institute Inc., The SAS System for Windows, Release 8.02, SAS System Help, CALL SLEEP, Cary, NC: SAS Institute Inc. SAS Institute Inc., The SAS System for Windows, Release 8.02, SAS System Help, CALL SOUND, Cary, NC: SAS Institute Inc. 4

TRADEMARK CITATION 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 registered trademarks or trademarks of their respective companies. ACKNOWLEDGEMENTS The author would like to express his appreciation to the following people for their assistance in this paper: Wendy Cuthbert, AAI Development Services CONTACT INFORMATION Contact the author at: David Fielding AAI Development Services Mississauga, Ontario, L5N 2W3 Work Phone: 905-816-9442 Fax: 905-816-9536 E-mail: david.fielding@aaidevelopment.com 5