Going Beyond Proc Tabulate Jim Edgington, LabOne, Inc., Lenexa, KS Carole Lindblade, LabOne, Inc., Lenexa, KS

Similar documents
Writing Reports with the

Introducing a Colorful Proc Tabulate Ben Cochran, The Bedford Group, Raleigh, NC

It s Proc Tabulate Jim, but not as we know it!

Setting the Percentage in PROC TABULATE

Chapters 18, 19, 20 Solutions. Page 1 of 14. Demographics from COLLEGE Data Set

BY S NOTSORTED OPTION Karuna Samudral, Octagon Research Solutions, Inc., Wayne, PA Gregory M. Giddings, Centocor R&D Inc.

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

DSCI 325: Handout 10 Summarizing Numerical and Categorical Data in SAS Spring 2017

Getting it Done with PROC TABULATE

Using PROC TABULATE and ODS Style Options to Make Really Great Tables Wendi L. Wright, CTB / McGraw-Hill, Harrisburg, PA

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

Proc Tabulate: Extending This Powerful Tool Beyond Its Limitations

Chapter 6: Modifying and Combining Data Sets

Christopher Toppe, Ph.D. Computer Sciences Corporation

Art Carpenter California Occidental Consultants

A Novel Approach to Developing a Patient Profile Reporting Application Steve Light and Paul Gilbert - DataCeutics Inc Guy Genereux - Sepracor Inc

Multiple Facts about Multilabel Formats

Paper S Data Presentation 101: An Analyst s Perspective

Using SAS to Analyze CYP-C Data: Introduction to Procedures. Overview

From Manual to Automatic with Overdrive - Using SAS to Automate Report Generation Faron Kincheloe, Baylor University, Waco, TX

SC-15. An Annotated Guide: Using Proc Tabulate And Proc Summary to Validate SAS Code Russ Lavery, Contractor, Ardmore, PA

Using SAS Macro to Include Statistics Output in Clinical Trial Summary Table

Applied Regression Modeling: A Business Approach

Stat 302 Statistical Software and Its Applications SAS: Data I/O

SAS Macros for Grouping Count and Its Application to Enhance Your Reports

Stat 302 Statistical Software and Its Applications SAS: Data I/O & Descriptive Statistics

SAS Example A10. Output Delivery System (ODS) Sample Data Set sales.txt. Examples of currently available ODS destinations: Mervyn Marasinghe

Reading data in SAS and Descriptive Statistics

Topics of Discussion

Uncommon Techniques for Common Variables

PowerPoint Presentation to Accompany GO! All In One. Chapter 13

Unit 3 Fill Series, Functions, Sorting

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center

I AlB 1 C 1 D ~~~ I I ; -j-----; ;--i--;--j- ;- j--; AlB

Excel Formulas & Functions I CS101

EXST SAS Lab Lab #6: More DATA STEP tasks

Basic Concepts #6: Introduction to Report Writing

PIVOT TABLES IN MICROSOFT EXCEL 2016

Using PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA

STAT:5400 Computing in Statistics

STIDistrict Query (Basic)

Identifying Duplicate Variables in a SAS Data Set

A Cross-national Comparison Using Stacked Data

STAT 503 Fall Introduction to SAS

Data Analysis and Solver Plugins for KSpread USER S MANUAL. Tomasz Maliszewski

Anyone Can Learn PROC TABULATE, v2.0

Automatically Generating a Customized Table for Summarizing the Activities in Clinics

%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables

STAT:5201 Applied Statistic II

Lab #1: Introduction to Basic SAS Operations

Quick Start Guide. Version R94. English

Data Should Not be a Four Letter Word Microsoft Excel QUICK TOUR

Alacart: Poor Man s Classification Trees

Chapter 23. Creating Reports with ifix

Mastering the Grade Book

Essentials of the SAS Output Delivery System (ODS)

Version 8 Base SAS Performance: How Does It Stack-Up? Robert Ray, SAS Institute Inc, Cary, NC

To complete this workbook, you will need the following file:

1. Basic Steps for Data Analysis Data Editor. 2.4.To create a new SPSS file

StatCalc User Manual. Version 9 for Mac and Windows. Copyright 2018, AcaStat Software. All rights Reserved.

Creating Macro Calls using Proc Freq

Contents of SAS Programming Techniques

APPENDIX B EXCEL BASICS 1

Defining Test Data Using Population Analysis Clarence Wm. Jackson, CQA - City of Dallas CIS

PROC SUMMARY AND PROC FORMAT: A WINNING COMBINATION

PROC REPORT Basics: Getting Started with the Primary Statements

Ten Great Reasons to Learn SAS Software's SQL Procedure

SAS Institue EXAM A SAS Base Programming for SAS 9

Using PROC SQL to Generate Shift Tables More Efficiently

Taming a Spreadsheet Importation Monster

%ANYTL: A Versatile Table/Listing Macro

SAS/STAT 13.1 User s Guide. The NESTED Procedure

/********************************************/ /* Evaluating the PS distribution!!! */ /********************************************/

SAS Survey Report Macro for Creating User-Friendly Descriptive Summaries

Kaseya 2. User Guide. Version 7.0. English

ReadyResults.net Viewing, Printing, and Customizing Reports. For help, send to: or call:

Automating Preliminary Data Cleaning in SAS

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma

EDUCATION IN PROC TABULATE I EDUCATION IN PROC TABULATE II

Lab 1: Introduction to Data

A Practical and Efficient Approach in Generating AE (Adverse Events) Tables within a Clinical Study Environment

Tweaking your tables: Suppressing superfluous subtotals in PROC TABULATE

Fact Sheet No.1 MERLIN

Creating output datasets using SQL (Structured Query Language) only Andrii Stakhniv, Experis Clinical, Ukraine

Basic Commands. Consider the data set: {15, 22, 32, 31, 52, 41, 11}

STA 570 Spring Lecture 5 Tuesday, Feb 1

Introductory Guide to SAS:

Ivy s Business Analytics Foundation Certification Details (Module I + II+ III + IV + V)

Statistics with a Hemacytometer

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Ćw. IV. DynamicTables

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

CHAPTER 4: MICROSOFT OFFICE: EXCEL 2010

A Side of Hash for You To Dig Into

Ranking Between the Lines

How to Remove Duplicate Rows in Excel

STATS PAD USER MANUAL

If you finish the work for the day go to QUIA and review any objective you feel you need help with.

WHO STEPS Surveillance Support Materials. STEPS Epi Info Training Guide

Introduction to Statistical Analyses in SAS

Transcription:

Going Beyond Proc Tabulate Jim Edgington, LabOne, Inc., Lenexa, KS Carole Lindblade, LabOne, Inc., Lenexa, KS ABSTRACT PROC Tabulate is one of the most powerful and versatile of the SAS reporting tools. It is one of very few SAS procedures that allows you to both compute statistics and have extensive control over the display of the results. It is also compatible with the ODS report delivery system built into version 8 SAS. Even with these advantages, there are limits to what the basic PROC can do. PROC Tabulate has a limited set of default statistics that do include some commonly used descriptive statistics, including median. It also is limited to only four types of denominators for various percentage calculations. Finally, until version 8, PROC Tabulate had to be used in isolation, as the results were trapped in the output and not available to the rest of the SAS program. INTRODUCTION With the ability to load data sets, you can both include all the statistical power of Univariate, ANOVA, or any of the other highly computational PROCs that are part of the SAS system, while maintaining the look and feel that your users have come to expect. And new in version 8, the ability to export data sets from PROC Tabulate, allows you to send your data to PROC Report, or even export the results directly to an MS Excel spreadsheet. Some previous limitations encountered using PROC Tabulate have been eliminated, and powerful alternatives are now available. This paper assumes that you have a basic understanding of PROC Tabulate. The purpose of this paper is to extend beyond what Tabulate can provide by itself; teaching the reader how to use other parts of SAS and integrate that knowledge to extend the capabilities of PROC Tabulate. EXTENDING STATISTICS AVAILABLE IN PROC TABULATE The following statistics are included with PROC Tabulate and are available with any cross of the analysis data set. These statistics include the number of observations, number of missing observations, maximum, minimum, range, sum, percentage of observations, and the percentage of the sum. Also included in Tabulate are higher-level statistics including sum of squares, variance, coefficient of variance, standard deviation, standard error, and various T-tests. While this covers the basics of statistical reporting, SAS has a vast array of statistics not included in this list. Here is an example of how you can load non-standard statistics into PROC Tabulate: Calculations that are beyond PROC Tabulate s abilities are performed using another PROC or a DATA step. The resulting data set must contain a unique index of the class variables. A unique index means that the data set has one and only one row for each combination of class variables. It also must contain the calculated value that is the result of the DATA step or PROC. Then create the PROC Tabulate as normal, with the following exception: Instead of using Tabulate to calculate the values, sum the total of all the analysis variables. Since you have a single record for the lowest level of the class combination, this sum is equal to the result you calculated by the alternative method. In this example we want to calculate a median, a function not found in PROC Tabulate, but rather in PROC Univariate, a procedure with very poor reporting characteristics. ; 1998MCocaine 101998FPCP 151998MMarijuan 121998FMorphine 01998FAlcohol 0 1998MCocaine 01998FPCP 221998FMarijuan 121998MMorphine 31998MAlcohol 2 1998MCocaine 01998FPCP 51998FMarijuan 21998MMorphine 61998FAlcohol 7 1998MCocaine 31998FPCP 251998MMarijuan 21998FMorphine 41998MAlcohol 9 1998FCocaine 321998MPCP 121998FMarijuan 01998FMorphine 01998MAlcohol 0 1999MCocaine 111999FPCP 01999MMarijuan 01999FMorphine 01999FAlcohol 1 1999MCocaine 101999FPCP 01999FMarijuan 01999MMorphine 01999MAlcohol 3 1999MCocaine 101999FPCP 01999FMarijuan 01999MMorphine 01999FAlcohol 6 1999MCocaine 301999FPCP 01999MMarijuan 01999FMorphine 01999MAlcohol 5 1999FCocaine 01999MPCP 01999FMarijuan 01999FMorphine 01999MAlcohol 9; proc sort data=mydata; by year sex test; proc univariate data=mydata noprint; by year sex test; var result; output out=stats n=n max=max min=min mean=mean median=median; proc tabulate data=stats; class year sex test; var n max min mean median; table year='year' * sex='gender', test*(n='n'*sum=' ' max='max'*sum=' ' min='min'*sum=' ' mean='mean'*sum=' ' median='median'*sum=' ') /rts=20; title 'Example of Loading Statistics into PROC

Tabulate'; Example of Loading Statistics into PROC Tabulate ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ test ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Alcohol ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ N Max Min Mean Median ƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ Year Gender ƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒ 1998 F 2.00 7.00 0.00 3.50 3.50 ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ M 3.00 9.00 0.00 3.67 2.00 ƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ 1999 F 2.00 6.00 1.00 3.50.50 ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ M 3.00 9.00 3.00 5.67 5.00 Šƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒœ CALCULATING NON-STANDARD PERCENTAGES PROC Tabulate has built-in percentage calculations for both the percentage of total observations and the percentage of the sum of an analysis variable s total value. These are the PCTN and PCTSUM functions. While these often provide sufficient percentage calculations, there are times when a different method of calculating percentages is desirable. One example is when dealing with missing values. PROC Tabulate with the MISSING option in the command line will treat a missing value as its own category. However, there are times when you wish to include missing value counts, but do not want to include them in the percentage breakdown of the different categories. In order to display these values, again the values must be calculated outside of PROC Tabulate, but now the programmer has total control over how the values are calculated. best4. best4. best4. best4. best4.; 1998MCocaine 101998FPCP 151998MMarijuan 121998FMorphine 01998FAlcohol 0 1998MCocaine 01998FPCP 221998FMarijuan 121998MMorphine 31998MAlcohol 2 1998MCocaine 01998FPCP 51998FMarijuan 21998MMorphine 61998FAlcohol 7 1998MCocaine 31998FPCP 251998MMarijuan 21998FMorphine 41998MAlcohol 9 1998FCocaine 321998MPCP 121998FMarijuan 01998FMorphine 01998MAlcohol 0 1999MCocaine 111999FPCP 01999FAlcohol 1 1999MCocaine 101999FPCP 01999MAlcohol 3 1999MCocaine 101999FPCP 01999FAlcohol 6 1999MCocaine 301999FPCP 01999MAlcohol 5 1999FCocaine 01999MPCP 01999FMarijuan 01999FMorphine 01999MAlcohol 9 1998MCocaine.1998FPCP.1998MMarijuan.1998FMorphine 1998FCocaine.1998MPCP.1998FMarijuan.1998FMorphine 1999MCocaine.1999FPCP.1999MMarijuan.1999FMorphine.1999FAlcohol. 1999MCocaine.1999FPCP.1999FMarijuan.1999MMorphine.1999MAlcohol. ; proc sort data=mydata; by year sex test; data tabload(keep = year sex test cnt_test tot_test cnt_miss); set mydata; by year sex test; retain tot_test cnt_test cnt_miss 0; if first.test then do; cnt_test = 0; cnt_miss = 0; if result ne. then do; cnt_test = cnt_test + 1; tot_test = tot_test + 1; else cnt_miss = cnt_miss + 1; if last.test then proc sort data=tabload; by descending year descending sex descending test;

data tabload1(drop = total tot_test); set tabload; retain total 0; if _n_ = 1 then total = tot_test; if cnt_test ne. then cnt_per = cnt_test / total * 100; else cnt_per = 0; Example of Loading Percentages into PROC proc tabulate data=tabload1 missing; class year sex test; table year='year' * sex='gender', test*(cnt_test='tests'*sum=' '*f=5. cnt_per='%'*sum=' '*f=6.1 cnt_miss='miss'*sum= ' '*f=5.) /rts=16; ƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ test ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Alcohol Cocaine Marijuan Morphine PCP ƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒˆƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒˆƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒˆƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒˆƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒ Tests % Miss Tests % Miss Tests % Miss Tests % Miss Tests % Miss ƒƒƒƒƒƒ ƒƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒ Year Gender ƒƒƒƒƒƒˆƒƒƒƒƒƒƒ 1998 F 2 4.0 0 1 2.0 1 3 6.0 1 3 6.0 2 4 8.0 1 ƒƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒ M 3 6.0 2 4 8.0 1 2 4.0 1 2 4.0 0 1 2.0 1 ƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒ 1999 F 2 4.0 1 1 2.0 0 3 6.0 1 3 6.0 1 4 8.0 2 ƒƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒˆƒƒƒƒƒƒˆƒƒƒƒƒ M 3 6.0 1 4 8.0 2 2 4.0 1 2 4.0 1 1 2.0 0 Šƒƒƒƒƒƒ ƒƒƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒ ƒƒƒƒƒƒ ƒƒƒƒƒœ PROC Tabulate can calculate four types of percentages percentages for a row, a column, a page or the entire population as the denominator. By using a data set the programmer can control how the percentages are calculated. Beginning with version 8.0, there is no need to figure the class variables involved in calculating percentages. COLPCTN, COLPCTSUM, ROWPCTN, ROWPCTSUM, PAGEPCTN, PAGEPCTSUM REPPCTN, and REPTPCTSUM, are new keywords that will calculate the appropriate percentages desired. No denominator definition is needed. You simply cross the percent keyword with the analysis variable on the table statement. Even with this new feature, these four types of percentages are often insufficient. Below is an example of producing one table, displaying two different populations. The advantage is that you can compare two different populations on one page, making a more meaningful table. input comp_cd $1. year $4. sex $1. test $8. result best4. best4. best4. best4. best4.; A1998MCocaine 101998FPCP 151998MMarijuan 121998FMorphine 01998FAlcohol 0 B1998MCocaine 01998FPCP 221998FMarijuan 121998MMorphine 31998MAlcohol 2 A1998MCocaine 01998FPCP 51998FMarijuan 21998MMorphine 61998FAlcohol 7 B1998MCocaine 31998FPCP 251998MMarijuan 21998FMorphine 41998MAlcohol 9 A1998FCocaine 321998MPCP 121998FMarijuan 01998FMorphine 01998MAlcohol 0 B1999MCocaine 111999FPCP 01999FAlcohol 1 A1999MCocaine 101999FPCP 01999MAlcohol 3 B1999MCocaine 101999FPCP 01999FAlcohol 6 A1999MCocaine 301999FPCP 01999MAlcohol 5 B1999FCocaine 01999MPCP 01999FMarijuan 01999FMorphine 01999MAlcohol 9 A1998MCocaine.1998FPCP.1998MMarijuan.1998FMorphine B1998FCocaine.1998MPCP.1998FMarijuan.1998FMorphine A1999MCocaine.1999FPCP.1999MMarijuan.1999FMorphine.1999FAlcohol. B1999MCocaine.1999FPCP.1999FMarijuan.1999MMorphine.1999MAlcohol. ; proc sort data=mydata; by comp_cd year sex test; data tabload(keep = comp_cd year sex test cnt_test tot_comp cnt_miss); set mydata; by comp_cd year sex test; retain tot_comp cnt_test cnt_miss 0; if first.comp_cd then tot_comp = 0; if first.test then cnt_test = 0; if result ne. then do; cnt_test = cnt_test + 1;

tot_comp = tot_comp + 1; else cnt_miss = cnt_miss + 1; if last.test then proc sort data=tabload; by descending comp_cd descending year descending sex descending test; data tabload1(drop = total tot_comp); set tabload; retain total 0; if _n_ = 1 then total = tot_comp; Example of Loading Percentages into PROC Tabulate cnt_per = cnt_test / total * 100; proc tabulate data=tabload1; class comp_cd year sex test; table year='yr' * sex='sex', comp_cd='co.'*test*(cnt_test='test'*sum=' '*f=4. cnt_per='%'*sum=' '*f=3.1 cnt_miss='mis'*sum= ' '*f=3.) /rts=11; ƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Co. ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ A B ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ test test ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒ Alcohol Cocaine Marijuan Morphine PCP Alcohol Cocaine Marijuan Morphine PCP ƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒˆƒƒƒƒ ƒƒƒ ƒƒƒ Test % Mis Test % Mis Test % Mis Test % Mis Test % Mis Test % Mis Test % Mis Test % Mis Test % Mis Test % Mis ƒƒƒƒ ƒƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒ Yr Sex ƒƒƒƒˆƒƒƒƒ 1998 F 2 8.0 0 1 4.0 0 2 8.0 0 2 8.0 1 2 8.0 2... 0 0.0 11 1 4.0 12 1 4.0 13 2 8.0 13 ƒƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒ M 1 4.0 3 2 8.0 4 1 4.0 5 1 4.0 5 1 4.0 5 2 8.0 14 2 8.0 14 1 4.0 14 1 4.0 14 0 0.0 15 ƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒ 1999 F 0 0.0 6... 1 4.0 6 1 4.0 7 2 8.0 8 2 8.0 15 1 4.0 15 2 8.0 16 2 8.0 16 2 8.0 17 ƒƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒƒˆƒƒƒˆƒƒƒ M 2 8.0 8 2 8.0 9 1 4.0 10 1 4.0 10... 1 4.0 18 2 8.0 19 1 4.0 19 1 4.0 20 1 4.0 20 Šƒƒƒƒ ƒƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒ ƒƒƒƒ ƒƒƒ ƒƒƒœ EXPORTING PROC TABULATE TO A DATA SET New in version 8, PROC Tabulate can now export a data set containing all the information to reproduce the Tabulate output. In order to use this feature, you must understand how the data set is structured. Take the Tabulate function from the last example and add OUT=MyTab to the initial line and the results of the PROC Tabulate is stored in a data set. Follow this with a PROC CONTENTS and a PROC PRINT to see what has been created. proc tabulate data=tabload1 out=mytab; class comp_cd year sex test; The CONTENTS Procedure Data Set Name: WORK.MYTAB Observations: 37 Member Type: DATA Variables: 10 Engine: V8 Indexes: 0 Created: 10:17 Tuesday, August 14, 2001 Observation Length: 64 Last Modified: 10:17 Tuesday, August 14, 2001 Deleted Observations: 0 Protection: Compressed: NO Data Set Type: Sorted: NO Label: -----Engine/Host Dependent Information----- Data Set Page Size: 8192 Number of Data Set Pages: 1 First Data Page: 1 Max Obs per Page: 127 Obs in First Data Page: 37 Number of Data Set Repairs: 0 File Name: D:\TEMP\SAS Temporary Files\_TD74\mytab.sas7bdat Release Created: 8.0101M0 Host Created: WIN_NT table year='yr' * sex='sex', comp_cd='co.'*test*(cnt_test='test'*sum=' '*f=4. cnt_per='%'*sum=' '*f=3.1 cnt_miss='mis'*sum= ' '*f=3.) /rts=11; proc contents data=mytab; proc print data=mytab uniform; -----Alphabetic List of Variables and Attributes----- # Variable Type Len Pos Label ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 6 _PAGE_ Num 8 0 Page for Observation 7 _TABLE_ Num 8 8 Table for Observation 5 _TYPE_ Char 4 54 Type of Observation 10 cnt_miss_sum Num 8 32 9 cnt_per_sum Num 8 24 8 cnt_test_sum Num 8 16 1 comp_cd Char 1 40 3 sex Char 1 45 4 test Char 8 46 2 year Char 4 41 cnt_ cnt_ cnt_ Obs comp_cd year sex test _TYPE PAGE TABLE_ test_sum per_sum miss_sum

1 A 1998 F Alcohol 1111 1 1 2 8 0 2 A 1998 F Cocaine 1111 1 1 1 4 0 3 A 1998 F Marijuan 1111 1 1 2 8 0 4 A 1998 F Morphine 1111 1 1 2 8 1 5 A 1998 F PCP 1111 1 1 2 8 2 6 B 1998 F Cocaine 1111 1 1 0 0 1 7 B 1998 F Marijuan 1111 1 1 1 4 12 8 B 1998 F Morphine 1111 1 1 1 4 13 9 B 1998 F PCP 1111 1 1 2 8 13 10 A 1998 M Alcohol 1111 1 1 1 4 3 11 A 1998 M Cocaine 1111 1 1 2 8 4 12 A 1998 M Marijuan 1111 1 1 1 4 5 13 A 1998 M Morphine 1111 1 1 1 4 5 14 A 1998 M PCP 1111 1 1 1 4 5 15 B 1998 M Alcohol 1111 1 1 2 8 14 16 B 1998 M Cocaine 1111 1 1 2 8 14 17 B 1998 M Marijuan 1111 1 1 1 4 14 18 B 1998 M Morphine 1111 1 1 1 4 14 19 B 1998 M PCP 1111 1 1 0 0 15 20 A 1999 F Alcohol 1111 1 1 0 0 6 21 A 1999 F Marijuan 1111 1 1 1 4 6 22 A 1999 F Morphine 1111 1 1 1 4 7 23 A 1999 F PCP 1111 1 1 2 8 8 24 B 1999 F Alcohol 1111 1 1 2 8 15 25 B 1999 F Cocaine 1111 1 1 1 4 15 26 B 1999 F Marijuan 1111 1 1 2 8 16 27 B 1999 F Morphine 1111 1 1 2 8 16 28 B 1999 F PCP 1111 1 1 2 8 17 29 A 1999 M Alcohol 1111 1 1 2 8 8 30 A 1999 M Cocaine 1111 1 1 2 8 9 31 A 1999 M Marijuan 1111 1 1 1 4 10 32 A 1999 M Morphine 1111 1 1 1 4 10 33 B 1999 M Alcohol 1111 1 1 1 4 18 34 B 1999 M Cocaine 1111 1 1 2 8 19 35 B 1999 M Marijuan 1111 1 1 1 4 19 36 B 1999 M Morphine 1111 1 1 1 4 20 37 B 1999 M PCP 1111 1 1 1 4 20 SUBHEAD (HEADER 2) Each row in the data table represents a unique level of the Class definition of the PROC Tabulate report. The various CLASS variables from the PROC Tabulate are included in the data set. (In this example, the CLASS Variables are YEAR, SEX, and TEST.) The analysis variables are calculated, and the value of the cell is assigned. Since there are three analysis variables, three variables are created. (cnt_test_sum, cnt_per_sum, cnt_miss_sum). Three new variables are also created: _type_, _page_, and _table_. Each of these variables represents an individual cell. The _type_ variable is created in a manner similar to the _type_ variable found in PROC Summary. This is a text variable that stores a binary number that indicates which members of the Class variables contributed to its total. The first character represents the first Class variable, the second character, the second class variable, and so on. In our example, all these values are 1 or true. Had we used PROC Tabulate s ability to subtotal, the noncontributing factors would have been 0. This will allow the user to extract the results from PROC Tabulate and use the data in various other PROCs. CONCLUSION PROC Tabulate is one of the most powerful reporting tools in the SAS system. Even so, Tabulate has its limitations. By using other SAS PROCs and the Data step procedure, you can extend the power of Tabulate beyond its original limitations. In this exercise, we have shown how to load the results of other PROCs by calculating the results as distinct values of the class variables and summing those results. We have also shown various methods of calculating percentages other than the default statistics found in PROC Tabulate. And finally, we have shown that in SAS Version 8 the results of Tabulate can be exported into a SAS data set to be used elsewhere in your SAS program. Much of the specific information on the new features of PROC Tabulate, in particular the exporting of the data set and the new percentage functions found in version 8, were researched at the SAS web sit. (www.sas.com) ACKNOWLEDGMENTS We would like to thank Lisa Ousley with her help with the final editing of this paper. CONTACT INFORMATION (HEADER 1) Your comments and questions are valued and encouraged. Contact the author at: Jim Edgington LabOne, Inc. 10101 Renner Blvd Lenexa, KS 66203 W: (913) 577-1335 Fax: (913) 8884160 Email: jim.edgington@labone.com Carole Lindblade LabOne, Inc. 10101 Renner Blvd Lenexa, KS 66203 W: (913) 577-1350 Fax: (913) 8884160 Email: carole.lindblade@labone.com REFERENCES