Reporting Template. By Denis Fafard Business Analyst WCB - Alberta

Similar documents
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

Integrating Large Datasets from Multiple Sources Calgary SAS Users Group (CSUG)

Principles of Automation

A simplistic approach to Grid Computing Edmonton SAS Users Group. April 5, 2016 Bill Benson, Enterprise Data Scienc ATB Financial

While You Were Sleeping, SAS Was Hard At Work Andrea Wainwright-Zimmerman, Capital One Financial, Inc., Richmond, VA

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

SAS Programming Basics

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

Cuyahoga Community College Information Technology Services Automic Applications Manager Reference Document

Data Quality Review for Missing Values and Outliers

PREREQUISITES FOR EXAMPLES

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

Introduction to the SAS Macro Facility

NEW FEATURES OF ENTERPRISE GUIDE 6.1 MATT MALCZEWSKI, SAS CANADA

National Accounts for Microsoft Dynamics SL Installation and User s Guide

Administrator for Enterprise Clients: User s Guide. Second Edition

Essential ODS Techniques for Creating Reports in PDF Patrick Thornton, SRI International, Menlo Park, CA

A Way to Work with Invoice Files in SAS

SAS ENTERPRISE GUIDE USER INTERFACE

Accessing Data and Creating Data Structures. SAS Global Certification Webinar Series

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

Let SAS Help You Easily Find and Access Your Folders and Files

SAS Online Training: Course contents: Agenda:

Technical Paper. Defining a Teradata Library with the TERADATA Engine in SAS Management Console

Internet/Intranet, the Web & SAS

National Accounts for Microsoft Dynamics SL 2011 Installation and User s Guide

Exporting Variable Labels as Column Headers in Excel using SAS Chaitanya Chowdagam, MaxisIT Inc., Metuchen, NJ

What Is SAS? CHAPTER 1 Essential Concepts of Base SAS Software

Give m Their Way They ll Love it! Sarita Prasad Bedge, Family Care Inc., Portland, Oregon

Syntax Conventions for SAS Programming Languages

Electricity Forecasting Full Circle

Text Generational Data Sets (Text GDS)

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research

Contents of SAS Programming Techniques

Purchase this book at

EG 4.1. PC-SAS users. for. I C T EG 4.1 for PC-SAS Users. Thursday - May 7 th, 2009

An Automation Procedure for Oracle Data Extraction and Insertion

Technical Paper. Accessing a Microsoft SQL Server Database from SAS under Microsoft Windows

Installing Blank SiriusSQL Database 4.0

Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING

Table of Contents. User Manual

SAS System Powers Web Measurement Solution at U S WEST

Enterprise Client Software for the Windows Platform

Quicker Than Merge? Kirby Cossey, Texas State Auditor s Office, Austin, Texas

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

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

Improving Your Relationship with SAS Enterprise Guide Jennifer Bjurstrom, SAS Institute Inc.

A Practical Introduction to SAS Data Integration Studio

Congratulations. EPG Workshop

Reading in Data Directly from Microsoft Word Questionnaire Forms

Fall 2012 OASUS Questions and Answers

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

Tips for Mastering Relational Databases Using SAS/ACCESS

Document and Enhance Your SAS Code, Data Sets, and Catalogs with SAS Functions, Macros, and SAS Metadata. Louise S. Hadden. Abt Associates Inc.

Sage Intelligence Financial Reporting for Sage ERP X3 Report Designer: Oracle Setup Conversion Guidelines

SAS. Studio 4.1: User s Guide. SAS Documentation

A Mass Symphony: Directing the Program Logs, Lists, and Outputs

Introduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions

LOG ON TO LINUX AND LOG OFF

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

How do I connect to Peachtree using ODBC/OLEDB?

Balance Point Technologies, Inc. MAX Toolbar for Microsoft Dynamics GP. For MAX (SQL Server) User Guide

Program Validation: Logging the Log

Administering SAS Enterprise Guide 4.2

FOCUS ON REAL DESIGN AUTOMATE THE REST CUSTOMTOOLS GETTING STARTED GUIDE

Cardholder User Guide

Financial Management System

A Macro to Create Program Inventory for Analysis Data Reviewer s Guide Xianhua (Allen) Zeng, PAREXEL International, Shanghai, China

Better Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables

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

SAS Enterprise Guide Moving from 4.1 to 4.3 What s New and Different?

Programming Tips and Examples for Your Toolkit, III John Morrill, Pharmion Corporation, Overland Park, KS

A d v a n c e d M i c r o s o f t : Wo r d I n s e r t Ta b Links.. Hyperlink: Insert Hyperlink Bookmark: Bookmark Bookmark Bookmarks Insert

Liberate, a component-based service orientated reporting architecture

How to Keep Multiple Formats in One Variable after Transpose Mindy Wang

Control Structures. CIS 118 Intro to LINUX

8 Writing Device/PLC Data in Database

Professional outputs with ODS LATEX

Connecting BioNumerics to MySQL

Macros for Two-Sample Hypothesis Tests Jinson J. Erinjeri, D.K. Shifflet and Associates Ltd., McLean, VA

EDITING AN EXISTING REPORT

MicroStation. FDO Reader USER S MANUAL. [Företagets adress]

Doc. Version 1.0 Updated:

Call: SAS BI Course Content:35-40hours

REST API Operations. 8.0 Release. 12/1/2015 Version 8.0.0

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

Use SAS/AF, SCL and MACRO to Build User-friendly Applications on UNIX

Tips & Tricks. With lots of help from other SUG and SUGI presenters. SAS HUG Meeting, November 18, 2010

Step-by-Step Guide to Ansur Executive 3.0 Installation With or without Electronic Signatures

SQL Server 2016 installation/setup instructions

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

inforouter V7 implementation Guide.

Tips and Tricks for SAS Programmers. SUCCESS March 2018 Mary Harding

Stat 302 Statistical Software and Its Applications SAS: Working with Data

Installation and Usage Guide

Paper Phil Mason, Wood Street Consultants

Getting Started With the Cisco PAM Desktop Software

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

Transcription:

Reporting Template By Denis Fafard Business Analyst WCB - Alberta

Problem Reports built to different standards - Hard to maintain - Hard to support unless you re the author Time Consuming to login and access the same databases all the time New BAs do not have a standard to follow - Difficult to learn all others styles - Tough to remember all database names (30+)

Solution Set up a single standard for coding reports Put all the repeated database login code into a single SAS file. Abstract out the need to remember specific database names.

******************************************************************************** * Report Title: esug Sample Report * Requested by: Matt Malczewski * Purpose/Desc: Sample report that really does nothing but show the logon procedure to access * data. SAS report below is strictly a sample and is probably filled with syntax errors. * * Criteria: Acct registered not prior to current year, * Credit Balance greater than $100. * Account must be open. * * Schedule: Ad-Hoc * Author: Denis Fafard Date: Nov 6, 2013 * * Modifications * CCYY-MM-DD: ZZ %1% ******************************************************************************** ; %INCLUDE '\\ReportServer\BA\Denis\PathNames.sas'; %INCLUDE "&InputPath\MTAnyOBS.SAS"; %LET ENVIRON=PROD; %INCLUDE "&ODBCPath\ODBC_IFMS.SAS"; %LET ENVIRON=PROD; %INCLUDE "&ODBCPath\ODBC_AIMS.SAS"; *Set up all pathnames; *Utility for checking empty data; *PS Financials Database; *Acct Registration Database; Data _Null_; * Set up variables to be used for this report; RegDT = INTNX('YEAR',Today(),0,'B'); OutFile = "&TempPath\Credit_Acct.HTM"; *OutFile = "&ReportPath\Credit_Acct.HTM"; Bal_Limit = -100; *Get the beginning of the year; *Report output file; *Minimum Credit Amt; Call SymputX('RegDT',RegDT); Call Symputx('OutFile',OutFile); Call Symputx('Bal_Limit',Bal_Limit); * Go find all the accounts for the given year with credit balances; Proc SQL; Create Table Credits as Select Cust_ID, Bal_amt From IFMS.PS_Cust_Data Where Bal_Amt LT &Bal_Limit; QUIT;

CONTINUED FROM PREVIOUS SLIDE * Go Find all the open accounts. This could be combined with above SQL; Proc SQL; Create Table Open_Acct as Select Cust_ID, Start_DT From AIMS.Employer1 Where Acct_Sts = 'OPEN' AND Start_DT GE RegDT; QUIT; Proc Sort Data=Credits NOEQUALS; By Cust_ID; Proc Sort Data=Open_Acct NOEQUALS; By Cust_ID; * Merge the data into the final table for output; Data Final; Merge Open_Acct (IN=Opn Drop=Start_DT) Credits (IN=CR); By Cust_ID; If Opn AND CR; *Put the results out into a simple HTML file; ODS HTML BODY = "&OutFile"; Proc Print Data=Final NOOBS Label Split='/'; Label Cust_ID = 'Account/Number' Bal_Amt = 'Balance/Amount'; Format Bal_Amt Dollar15.2 ; Title 'Credits on Open Accounts'; FOOTNOTE1 j=center color=blue height=10pt "Data run as of &SYSDATE9 at &SYSTIME"; ods _all_ close; /****************************************** *** THIS IS THE END. *** *******************************************/

PATHNAMES.SAS /*---------------------------------------------------------*/ /* SAS Macro Definition for Paths to Folders */ /* This file should be included into the SAS program via */ /* the %include statement. For example: */ /* %include "PathNames.sas"; */ /* Any libname, infile, file, or filename statements can */ /* reference this path using the syntax: */ /* libname xxxx "&temppath\subdirxxx"; */ /* filename xxxx "&temppath\yyyyyyyy"; */ /* Local version for Denis Fafard. */ /* DO NOT COPY THIS PROGRAM INTO THE PRODUCTION DIRECTORY. */ /*---------------------------------------------------------*/ %global TempPath; %let TempPath = C:\Users\Denis\Downloads; /* Path to MS Excel */ %global MSExcel; %let MSExcel = C:\Program Files\Microsoft Office\OFFICE11\Excel.exe; /* Path for all ODBC drivers & security type files */ %global ODBCPath; %let ODBCPath = \\ReportServer\BA\Denis\ODBC; /* Standard Output path for public reports */ %global ReportPath; %let ReportPath = \\ReportServer\BA\Reports; /* For all input programs. */ %global InputPath; %let InputPath = \\ReportServer\BA\Denis;

ODBC_IFMS.SAS /*---------------------------------------------------------------------------** ** GENERIC ODBC DRIVER FOR PS/IFMS ** ** ** ** This file should be included in your main SAS file in a line such as ** ** %INCLUDE "&ODBCPath\ODBC_IFMS.SAS" ** ** ** ** This will set up an "IFMS" libname to link to IFMS in either production, ** ** pre-production (not all tables available) or development, based on the ** ** global macro variable "ENVIRON". ** ** ** ** REQUIRED: The following variable must be set in the calling program: ** ** %LET ENVIRON=xxxxxx; ** ** ** ** Where xxxxxx = PROD, PREPROD, TRAINING or any development IFMS schema ** ** (e.g. QTV1, QTU9, QTI2,...) ** ** ** ** To use this libname, call "IFMS" inside PROC SQL. E.g., ** ** SELECT * ** ** FROM IFMS.PS_DUN_CUST ** **---------------------------------------------------------------------------** ** If this ODBC driver uses RACF security set RACF=1 ** ** If this ODBC driver uses Windows security set RACF=0 ** **---------------------------------------------------------------------------*/ %GLOBAL RACF ; %LET RACF = 1 ; %INCLUDE "&ODBCPath\SECURITY.SAS"; DATA _NULL_; ENVIRON=UpCase(SYMGET('ENVIRON')); IF ENVIRON='PROD' THEN DO; CALL SYMPUTX('SCHEMA','QTP1'); CALL SYMPUTX('DATASRC','IFMSP'); END; ELSE IF ENVIRON='PREPROD' THEN DO; CALL SYMPUTX('SCHEMA','QTR1'); CALL SYMPUTX('DATASRC','IFMSR'); END; ELSE IF ENVIRON='TRAINING' THEN DO; CALL SYMPUTX('SCHEMA','QTE1'); CALL SYMPUTX('DATASRC','IFMSE'); END; ELSE DO; CALL SYMPUTX('SCHEMA',ENVIRON); CALL SYMPUTX('DATASRC','IFMSU'); END;

... CONTINUED FROM PREVIOUS SLIDE... ODBC_IFMS.SAS LIBNAME IFMS ODBC DBPROMPT=&DBPROMPT DEFER=NO USER=&USER PASSWORD=&PASSWORD DATASRC=&DATASRC SCHEMA=&SCHEMA; Data _Null_; /* Check to see if the LIBNAME function was successful. Password may have expired */ /* or even the ODBC call might have failed. Denis Fafard May 23, 2008 */ If &syslibrc NE 0 Then Do x = 1 to 10; Put 'ODBC Error - Check your password or ODBC driver.'; Put "User = <&User> DataSrc = <&DATASRC> Schema = <&SCHEMA>"; Put ' '; end; /* Uncomment next line if you prefer SAS to shutdown if LIBNAME fails. Abort Return */

SECURITY.SAS /*---------------------------------------------------------*/ /* SAS security parameters */ /* This file should be included into the SAS program via */ /* the %include statement. For example: */ /* %include "SECURITY.sas"; */ /* Parameters: */ /* user - Mainframe RACF user id */ /* dbprompt - prompting, YES or NO */ /* password - Mainframe RACF & Windows passwords */ /* <<<<<This should be a hidden & secure file>>>>>>> */ /* <<<<<<<<< BUAAHHHAAAHAAAAHAAAAA >>>>>>>>>>> */ /*---------------------------------------------------------*/ %GLOBAL USER DBPROMPT PASSWORD ; %LET USER = Denis9814 ; %LET DBPROMPT = NO ; Data _NULL_ ; Length PASSWORD $ 9 ; *Sets the max. length; If &RACF = 0 Then PASSWORD = "WindowPWD" ; If &RACF = 1 Then PASSWORD = "OtherPWD" ; Call Symput('PASSWORD',PASSWORD);

Overall Flow Main program Pathnames ODBC Driver Security File