Customized Reports with SAS Output Delivery System (ODS)

Download Report

Transcript Customized Reports with SAS Output Delivery System (ODS)

SAS Enterprise Guide Best of Both Worlds – Is it Right for You?

Sunil Gupta [email protected]

www.SASSavvy.com

SAS Enterprise Guide World SAS Display Manager World

SAS Display Manager World

Technical Requires More Time for Programming One Dataset/Program/Output File per window Open Programmer’s working environment (Interactive – DATA Step Debugger) Non-Visual Programming

SAS Enterprise Guide World

Non-Technical, Technical Requires Less Time for Programming using up to 90 Tasks Cross Reference/

Query Multiple Intermediate Datasets

/Programs/ Output Files Controlled Analyst’s working environment (Defaults, Batch Processing) Visual Process Flow 3

What’s in a Name?

SAS

Same Power as base SAS

Enterprise

Wide scope and integration with data source and output channels within ONE file

Guide

Free with PC SAS Standardize and automate tasks and queries, execute difficult or infrequently used SAS Procedures 4

What type of SAS User are you?

New/Experienced SAS Programmer – Create and run SAS programs Statistician – Exploratory statistical analysis, graphic templates Manager – As is or running stored procedures 5

What types of programming tasks are supported?

Data Access Import data or Data Step to access excel , raw data Data Management Query Builder and Edit Checks with Proc SQL Data Reporting Tasks Drag-n-Drop, Proc Tabulate, Proc Transpose Data Analysis ODS Statistical Graphics 6

Interface vs. Integrate SAS EG Camps

Run SAS Programs as separate files from one SAS EG project file. Trouble-shoot data issues with query management. Do not depend on SAS EG for production runs.

Embed SAS Programs within SAS EG. Use SAS EG tasks to help process data for analysis. Allow managers access to data and reports.

7

What If SAS EG Could?

• • Help with querying and validating? Query exploration and management • Help with documentation? More portable package format (Notes, SAS Program, List, Log and Output file) • Enforce standards and automation?

Fully compatible with SAS macros and menus Help with prototyping table layouts and performing complex statistical analysis? Yes with feature to create custom tasks 8

SAS Enterprise Guide: The Basics

Point-and-Click

All results are saved to one project file!

SAS Programming Required!

Drag-and-Drop

9

SAS Enterprise Guide: The Basics

Single Data set

Automatic access to current data

Enterprise Guide Task SAS Programs

Update SAS programs from within Enterprise Guide

Store all within one project file – program, log, & list.

Access results within one project file – RTF, PDF, & HTML.

10

SAS Enterprise Guide: The Basics Follows a Typical Process Flow Access Raw Data Create Query, Merge Data sets Create Variables, Formats Analysis & Reporting Results as RTF, HTML, etc.

Enterprise Guide tasks make programming easier!

11

Process Flow Diagram

12

Enterprise Guide: The Interface EG Windows - Project, Task, Workspace

13

Simulate SAS Display Manager

14

Enterprise Guide Task List

- Select by Category - Select by Task Name* - Select by Toolbar - Create RTF, HTML, PDF, etc.

Change the Output Style 15

Enterprise Guide Task List

Select by Task Name* - MEANS - FREQ etc.

* Many SAS procedures from SAS/BASE, SAS/GRAPH, SAS/STAT, SAS/ETS, SAS/QC

Ideal for programmers!

16

Enterprise Guide Task List

Select by Toolbar - Descriptive - List Data - Summary Statistics etc.

- Table Analysis etc.

Alternative to directly using SAS Procedures 17

Behind the scenes

18

Behind the scenes

19

Enterprise Guide Task Rules

Over 90 tasks to choose from

Each task is associated with a SAS Procedure - Simple Listing only for PROC REPORT

Task may not contain all SAS Procedure options - Can copy and customize SAS code

Once you learn one task, other tasks are similar - Organized as tabs to specify variables and options

First access data set or query before selecting tasks

-

Task needs to know the variables to display

Assure all variables exist in single data set or query

20

Which are the most profitable products?

Point-and-click the Sales data set to become active Point-and-click the Summary Tables Task Make the following tab selections TAB COLUMNS Description* Assign SALES and QUANTITY as Analysis variables Assign CATEGORY and PRODUCT as Classification variables TABLE Assign the following column variables: QUANTITY and SALES Assign the following row variables: CATEGORY and PRODUCT RESULTS TITLES No need to save results to a data set Enter text ‘Table 1.1 Sales Statistics by Product’ * Instructions Required

21

SAS Enterprise Guide: Tasks I. Project Setup Tasks II. Data Management Tasks III. Analysis and Reporting Tasks Process Training Required.

Logical sequence of events. Organized approach to non-programming.

22

I. Project Setup Tasks Project Setup Tasks Description_________

Create Code Assign Libname statement ex. libname dfile ‘c:\data’; Create Code* Create data set ex. data test; etc.; run; Create Format Create & Assign formats ex. proc format; etc.; run; * Programmer’s task - ex. proc report

Key Point: Access data sets and assign formats

23

II. Data Management Tasks Data Management Tasks Description_________

Create Query Add variables and formats ex. salegrp, salegrp.

Proc SQL

Apply subset condition ex. 2002 sales data Create Parameter Query* Add filter ex. Select a product * Can easily create a basic user-friendly interface

Key Point: Subset data set, create new variables,

24

useful for ad-hoc requests

A Create Query Task: Merge Data Sets B C

   

Points to data set (does not copy the data set) Be careful NOT to move the source data sets Can create new permanent data set Single data set or query is required for tasks

25

II. Data Management Tasks: Parameter Query

   

Example of one user prompt to ‘Select a Product’. Can add more variables to restrict query. Returns data set with only products selected. Can use data set as source for EG tasks.

26

III. Analysis and Reporting Tasks Analysis & Reporting Tasks Description__________

Summary Table Sales Statistics Table, ex. proc tabulate Listing Detail Sales Listing, ex. proc print Statistical Analysis Differences in yearly sales? ex. proc t-test Graphs How much have sales risen this year?

e

x. proc gchart

Key Points: Select the appropriate task, Query explore any intermediate dataset, Save all queries in project file

27

SAS Programming Options Four Points of Custom Program Entry ________

1. Execute code when first opening project file such as setup.sas.

2. Execute code before or after running a task.

3. Insert custom code at predetermined points within a task to run with task. Examples include before or after DATA step or SAS Procedures and SAS Procedure statements or options. 4. Execute copied and customized generated code from task from a new program window. 28

Query Exploration and Management

Intermediate [Select Variables, Subset Condition, and Sort Order] Datasets LAB1 • Query 301 and labtest = ‘CHEM_ALB’ • Query 302 and labtest = ‘HEM_ANC’ (DATA step update to LAB2) LAB2 • Query 301 and labtest = ‘CHEM_ALB’ • Query 302 and labtest = ‘HEM_ANC’ LAB (DATA step update to LAB) • Characterize Data • Save as permanent dataset Recreate Queries How do you think dates are selected?

Graph Task: Chart Gallery

SAS Programming 30

Typical Business Model Different Viewpoints of the Same Data Viewpoint Example Question________________ Customer

Which are the most profitable customers?

Product

What are the product sales across market segments – Retail/Catalog?

Organization

How successful are the marketing and sales campaign promotions?

Once a table is created, it is easy to change the table to a different viewpoint!

31

Selecting Analysis and Reporting Tasks How well do you know your business?

WHICH IS THE BEST ?

PRODUCT?

CUSTOMER?

REGION?

MARKET SEGMENT?

TIME PERIOD?

PRODUCT GROWTH?

- Shoes - Acme - Northern - Retail Sales - 4

th Quarter, 2001

- Slippers

You’ve got questions, Enterprise Guide has answers!

32

SAS Enterprise Guide Best Practices Tips:

1. Some level of training is required.

2. Write to SAS programs instead of embedding the SAS programs to keep as separate files.

3. Take advantage of Notes Task to document steps.

4. Apply ‘Save As’ instead of ‘Save’ to prevent accidental replacement of another project file.

5. Be careful when saving files when multiple projects opened.

continue …

33

SAS Enterprise Guide Best Practices Tips:

6. Take advantage of process flow diagram to visualize project code and tasks.

7. Take advantage of split panel to simultaneously view dataset and SAS program.

8. Take advantage of order list option to create batch jobs.

9. Take advantage of viewing each HTML/RTF/PDF file, for example, when creating multiple files.

10. For best debugging, keep all unique intermediate dataset names to view each data step sequence.

continue …

34

SAS Enterprise Guide Best Practices Tips:

11. Put on your data mining hat to query explore most any intermediate dataset created to confirm assumptions.

12. Plan to follow a migration plan with your most open SAS programmers before your closed SAS programmers.

Build

Your

Own Best Practice Tips 35

SOP Compliance and Best Practices

36

Characterize Data Task – Categorical Data

Automatic for both character and numeric variables. Can specify number of unique values to display.

37

Characterize Data Task – Continuous Data

Automatic for each numeric variable.

38

Characterize Data Task – Continuous Data

Option to display as graphs or save as dataset.

39

SAS Programmers Tool - Syntax proc report data=mydatea.sales nowd split="*" headline; column product year,(quantity sales pct_prd) quantity=grd_tot sales=grd_pct; define product / group 'PRODUCT'; define year / across 'Sales by Year' center; define quantity / sum 'N' center format=comma6.; define sales / sum 'Total' format=dollar8.; define pct_prd / computed '% Total' width=5 format=pctf.; define grd_tot / sum 'QNTY Total' format=comma6.; define grd_pct / sum 'SALES Total' width=5 format=dollar8.; compute before; gt1=_c3_; gt2 = _c6_; gt3 = _c8_; endcomp; compute pct_prd; _c4_ = (_c3_/gt1)*100; _c7_ = (_c6_/gt2)*100; endcomp; rbreak after / summarize skip ol ul; compute after; product = 'Total'; endcomp; run; Yes, you can write your own code.

40

Moving EG Code to Production

All Enterprise Guide code can be exported

Enhance EG code with style options

Very useful to develop prototype without writing code

For any task, select Preview Task Code

Create Code Task (Programmer’s Task)

SAS EG 4.3 has fill-in editor and WHERE tab

41

SAS Enterprise Guide’s Top Three Unknown Benefits Top Four Unknown Benefits

Characterize Dataset Split screen to view multiple windows Query Multiple Intermediate Datasets Production Runs

Brief Description

Automatic PROC FREQ and PROC MEANS See both program and dataset or log files Save sort and filters for each data review Link and run programs in sequence 42

43

On-Demand SAS Demos

44

SASSavvy.com: Top SAS Enterprise Guide Papers

45

SAS Enterprise Guide Best of Both Worlds – Is it Right for You?

Sunil Gupta [email protected]

www.SASSavvy.com