Batch processing and sysparm A step towards scheduling.

Slides:



Advertisements
Similar presentations
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Advertisements

Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 11: Monitoring Server Performance.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
MCTS Guide to Microsoft Windows Server 2008 Network Infrastructure Configuration Chapter 8 Introduction to Printers in a Windows Server 2008 Network.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – Shell Programming The activities of.
Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
© 2004 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Automation Fundamental Concepts &
Managing Passwords in the SAS System Allen Malone Senior Analyst/Programmer Kaiser Permanente.
Introduction to Shell Script Programming
For Version 6.0 and later Lattice3D Reporter Tutorial For Version 6.0 and later LATTICE TECHNOLOGY, INC.
Chapter 9 Scripting RMAN. Background Authors felt that scripting was a topic not covered well Authors wanted to cover both Unix/Linux and Windows environments.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
SAS Options – Versatile Players in the Game of SAS Denise Poll, SAS Institute Inc.
INTRODUCTION TO SAS MACRO PROCESSING James R. Bence, Ph.D., Co-Director Quantitative Fisheries Center Professor Department of Fisheries and Wildlife March.
Copyright © 2006, SAS Institute Inc. All rights reserved. SAS Enterprise Guide Old Proc – New Tricks? Tim Trussell Academic Program, SAS Canada world diabetes.
Linux Operations and Administration
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
5/30/2010 SAS Macro Language Group 6 Pradnya Nimkar, Li Lin, Linsong Zhang & Loc Tran.
Oracle Data Integrator Procedures, Advanced Workflows.
Shell Programming. Creating Shell Scripts: Some Basic Principles A script name is arbitrary. Choose names that make it easy to quickly identify file function.
June 12, 2009 Toronto Area SAS Society 1 What’s new in BASE SAS 9.2 Checkpoint/Restart Rupinder Dhillon Dhillon Consulting Inc.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
Define your Own SAS® Command Line Commands Duong Tran – Independent Contractor, London, UK Define your Own SAS® Command Line Commands Duong Tran – Independent.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
Macro Variable Resolution Enio Presutto York University, Toronto, Canada.
Introduction to SAS Macros Center for Statistical Consulting Short Course April 15, 2004.
11 WORKING WITH PRINTERS Chapter 10. Chapter 10: WORKING WITH PRINTERS2 THE WINDOWS SERVER 2003 PRINTER MODEL  Locally attached printers Printers that.
Separating the Interface from the Engine: Creating Custom Add-in Tasks for SAS Enterprise Guide ® Peter Eberhardt Fernwood Consulting Group Inc.
Doug Haigh, SAS Institute Inc.
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
Guide to MCSE , Enhanced1 Activity 11-1: Using Task Manager to Manage Applications and Processes Objective: To explore managing applications and.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
Introduction to KE EMu Unit objectives: Introduction to Windows Use the keyboard and mouse Use the desktop Open, move and resize a.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Quick Test Professional 9.2. Testing Process Preparing to Record Recording Enhancing a Test Debugging Running the Test and Analyzing the Results Reporting.
GDT Tips and Tricks. GDT Tips and Tricks Doug Evans GDT 2004 International User Conference – Evolving the Legacy July  Tucson, Arizona GDT Tips.
Perfecto Mobile Automation
Oracle Business Intelligence Foundation – Testing and Deploying OBI Repository.
Chapter 5 The Bourne Shell Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Notes by Michael Weeks.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
Copyright © 2016, SAS Institute Inc. All rights reserved. HIDDEN GEMS IN SAS ENTERPRISE GUIDE.
Mainframe – Control-M Architecture.
Tips for Mastering Relational Databases Using SAS/ACCESS®
Scheduled Report ing From CounterPoint.
z/Ware 2.0 Technical Overview
What is Bash Shell Scripting?
Guide To UNIX Using Linux Third Edition
3 Iterative Processing.
Architecture + system-based How to assign passwords
Detecting Runtime Errors and Exiting from Nested Macros Gracefully
Automating SAS through the Power of VB Script
Passing Simple and Complex Parameters In and Out of Macros
Parallel Processing in Base SAS
CST8177 Scripting 2: What?.
Writing Robust SAS Macros
Presentation transcript:

Batch processing and sysparm A step towards scheduling

SAS modes of execution Foreground PC/SAS or SAS Display Manager Client server SAS/Connect or Enterprise Guide Background MVS JCL or Unix shell script Background SAS on MS Windows

PC/SAS native options Right-click on program.sas and Batch submit Batch submit from the SAS Viewer Windows command shell

Why bother? Majority of SAS users have repeatable tasks Every SAS user has access to a sas executable All platforms have background processing Operational groups do not know SAS We move on but our code may stay

Operational requirements Consistency Minimum intervention Process level control Isolation from other activity Graceful failure Parallel processing

Existing parallel processing options Enterprise Guide Process Designer Multiple sessions of EG or PC/SAS MP Connect systask coding SAS DI Studio Scripting

Principles of SAS scripting SAS business logic is read-only SAS code is portable and self contained Use parameters to control processing Use environment settings at initialisation Keep logs and listings

Combining existing techniques SAS macro functions Operating system scripting Process monitoring -sysparm startup option

SAS startup options Default options are defined in sasv9.cfg Options can be overridden at session startup -sysparm must be the last option Sas.exe –sysin annual.sas -sysparm “2007”

Enhancing simple reports Some basic code: %let year = 2004 ; proc print noobs data = sashelp.orsales ; where year=&year and product_line='Sports' ; run ;

Enhancing simple reports Some basic macro code: %macro orion_print(year) ; proc print noobs data = sashelp.orsales ; where year=&year and product_line='Sports' ; run ; %mend orion_print ; %orion_print(2004) ;

Enhancing simple reports Some read-only macro code: %macro orion_print(year) ; proc print noobs data = sashelp.orsales ; where year=&year and product_line='Sports' ; run ; %mend orion_print ; %orion_print(&sysparm.) ;

Enhancing simple reports Some more read-only macro code: %macro orion_print(year) ; proc print noobs data = sashelp.orsales ; where year=&year and product_line='Sports' ; run ; %mend orion_print ; %inc jobparms.txt ; /* Not read-only */ %orion_print(&year.) ;

Enhancing simple reports Some read-only macro code with basic check: %macro orion_print(year) ; proc print noobs data = sashelp.orsales ; where %if "&year" ^= "" %then %do ; year=&year and %end ; product_line='Sports' ; run ; %mend orion_print ; %orion_print(&sysparm.) ;

Putting it together Open cmd window in SAS code location Create script sas.bat pointing to "c:\Program Files\SAS\SAS 9.1\sas.exe" >sas macro_orion_print -sysparm '2004‘ Notice that macro_orion_print.log and macro_orion_print.lst have been created

Principles recap SAS business logic is read-only SAS code is portable and self contained Use parameters to control processing Keep logs and listings

Enhancements More source code control Automatic macro locations Return code trapping Logging Multiple parameter passing

Enhancing simple reports Production ready code: options mautosource sasautos=("&MLIB",'!sasroot/sasautos'); %orion_print(&sysparm.) ;

Sas91.bat DOS batch script echo off "C:\SAS\SAS_Home\SAS 9.1\sas_batch.exe" %* if errorlevel 2 if not errorlevel 3 goto err if errorlevel 1 if not errorlevel 2 goto warn if errorlevel 0 if not errorlevel 1 goto ok :warn echo SAS exited with a Warning. Check %1.log goto end :err echo SAS exited with a Error. Check %1.log echo Return code = %ERRORLEVEL% goto end :ok echo Seems OK. echo Return code = %ERRORLEVEL% echo Parm1 = %1 echo SASlog is %1.log :end echo End of sas91.bat

Adding more controls Add more parameters to basic code: %let year = 2004 ; %let pline = Sports ; proc print noobs data = sashelp.orsales ; where year=&year and product_line=“&pline” ; run ;

Adding more controls Add more parameters to macro: %macro orion_print2(year,pline) ; proc print noobs data = sashelp.orsales ; where year=&year and product_line=“&pline” ; run ; %mend orion_print 2; %multi_sysparm ; %orion_print2(year,pline) ;

Multi sysparm macro Accepts multiple name value pairs e.g –sysparm ‘name1=value1,name2=value2’ &name1 &name2 are %global

Sysparm splitting example %let sysparm = name1=value1,name2=value2,name3=value3 ; data _null_; length sysparm express param value $ 200; sysparm = symget('sysparm'); do i=1 to 50 until(express = ''); express = left(scan(sysparm, i, ',')); /* name=value */ param = left(upcase(scan(express, 1, '='))); /* name */ value = left(scan(express, 2, '=')); valid = not verify(substr(param, 1, 1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ_') and not verify(trim(param),'ABCDEFGHIJKLMNOPQRSTUVWXYZ_ ') and length(param) <=32 ; /* Ensure valid V8 macrovar name */ if valid then call symput(param, trim(left(value))); end; run; %put _user_ ; Gives GLOBAL NAME2 value2 GLOBAL NAME3 value3 GLOBAL NAME1 value1

Putting it together – Part 2 Open cmd window in SAS code location >..\scripts\sas91.bat macro_orion_print2 - sysparm “year=2001,pline=‘Sports‘”

Other additional information Google search string for SUGI and SGF papers: sysparm site:www2.sas.com filetype:pdf Peter Crawford’s very robust techniques for isolating PC-SAS projects Bernard Tremblay’s reference to Rick Aster’s split sysparm code How SAS startup configurations are decided Elaborate system that uses SYSTASK for controlling process flow Comprehensive Unix based production system Using SYSPARM and other automatic variables Very comprehensive and complicated script Windows Process Explorer Contact: Andrew Farrrer