Paper An Automated Reporting Macro to Create Cell Index An Enhanced Revisit. Shi-Tao Yeh, GlaxoSmithKline, King of Prussia, PA

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

EXPORTING SAS OUTPUT ONTO THE WORLD WIDE WEB

An Efficient Method to Create Titles for Multiple Clinical Reports Using Proc Format within A Do Loop Youying Yu, PharmaNet/i3, West Chester, Ohio

There s No Such Thing as Normal Clinical Trials Data, or Is There? Daphne Ewing, Octagon Research Solutions, Inc., Wayne, PA

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

Tales from the Help Desk 6: Solutions to Common SAS Tasks

STEP 1 - /*******************************/ /* Manipulate the data files */ /*******************************/ <<SAS DATA statements>>

Arthur L. Carpenter California Occidental Consultants, Oceanside, California

Validation Summary using SYSINFO

Data Quality Review for Missing Values and Outliers

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

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

SD10 A SAS MACRO FOR PERFORMING BACKWARD SELECTION IN PROC SURVEYREG

Going Under the Hood: How Does the Macro Processor Really Work?

Let s Get FREQy with our Statistics: Data-Driven Approach to Determining Appropriate Test Statistic

EXAMPLES OF DATA LISTINGS AND CLINICAL SUMMARY TABLES USING PROC REPORT'S BATCH LANGUAGE

Using PROC SQL to Generate Shift Tables More Efficiently

Prove QC Quality Create SAS Datasets from RTF Files Honghua Chen, OCKHAM, Cary, NC

So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines

A Cross-national Comparison Using Stacked Data

Hot-deck Imputation with SAS Arrays and Macros for Large Surveys

Developing Data-Driven SAS Programs Using Proc Contents

PharmaSUG Paper TT11

PROC REPORT AN INTRODUCTION

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

A Side of Hash for You To Dig Into

SAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD

PharmaSUG Paper TT10 Creating a Customized Graph for Adverse Event Incidence and Duration Sanjiv Ramalingam, Octagon Research Solutions Inc.

Clinical Data Visualization using TIBCO Spotfire and SAS

Cleaning Duplicate Observations on a Chessboard of Missing Values Mayrita Vitvitska, ClinOps, LLC, San Francisco, CA

Creating Macro Calls using Proc Freq

A Breeze through SAS options to Enter a Zero-filled row Kajal Tahiliani, ICON Clinical Research, Warrington, PA

Greenspace: A Macro to Improve a SAS Data Set Footprint

Want to Do a Better Job? - Select Appropriate Statistical Analysis in Healthcare Research

PDF Multi-Level Bookmarks via SAS

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

Statistics and Data Analysis. Common Pitfalls in SAS Statistical Analysis Macros in a Mass Production Environment

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

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

Programming Gems that are worth learning SQL for! Pamela L. Reading, Rho, Inc., Chapel Hill, NC

1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file

CMISS the SAS Function You May Have Been MISSING Mira Shapiro, Analytic Designers LLC, Bethesda, MD

PROC REPORT Basics: Getting Started with the Primary Statements

%ANYTL: A Versatile Table/Listing Macro

Using SAS Macros to Extract P-values from PROC FREQ

Compute Blocks in Report

PharmaSUG Paper SP04

Regaining Some Control Over ODS RTF Pagination When Using Proc Report Gary E. Moore, Moore Computing Services, Inc., Little Rock, Arkansas

Posters 417. NESUG '92 Proceedings. usinq Annotate Data sets to Enhance Contour Graphics output. Shi Tao Yeh, Environmental Resources Kanaqement, ~nc.

A Macro for Systematic Treatment of Special Values in Weight of Evidence Variable Transformation Chaoxian Cai, Automated Financial Systems, Exton, PA

SAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD

PharmaSUG 2013 CC26 Automating the Labeling of X- Axis Sanjiv Ramalingam, Vertex Pharmaceuticals, Inc., Cambridge, MA

A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN

Keeping Track of Database Changes During Database Lock

Get Started Writing SAS Macros Luisa Hartman, Jane Liao, Merck Sharp & Dohme Corp.

%MISSING: A SAS Macro to Report Missing Value Percentages for a Multi-Year Multi-File Information System

A Useful Macro for Converting SAS Data sets into SAS Transport Files in Electronic Submissions

Getting it Done with PROC TABULATE

Poster Frequencies of a Multiple Mention Question

General Tips for Working with Large SAS datasets and Oracle tables

How to Create Data-Driven Lists

Obtaining the Patient Most Recent Time-stamped Measurements

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

Square Peg, Square Hole Getting Tables to Fit on Slides in the ODS Destination for PowerPoint

Generating Customized Analytical Reports from SAS Procedure Output Brinda Bhaskar and Kennan Murray, RTI International

Checking for Duplicates Wendi L. Wright

A SAS Macro for Balancing a Weighted Sample

Get SAS sy with PROC SQL Amie Bissonett, Pharmanet/i3, Minneapolis, MN

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

Facilitate Statistical Analysis with Automatic Collapsing of Small Size Strata

A Macro to replace PROC REPORT!?

SAS Linear Model Demo. Overview

The Demystification of a Great Deal of Files

Are you Still Afraid of Using Arrays? Let s Explore their Advantages

Mapping Clinical Data to a Standard Structure: A Table Driven Approach

How to Implement the One-Time Methodology Mark Tabladillo, Ph.D., MarkTab Consulting, Atlanta, GA Associate Faculty, University of Phoenix

PhUSE US Connect 2018 Paper CT06 A Macro Tool to Find and/or Split Variable Text String Greater Than 200 Characters for Regulatory Submission Datasets

Planting Your Rows: Using SAS Formats to Make the Generation of Zero- Filled Rows in Tables Less Thorny

SAS Macro Technique for Embedding and Using Metadata in Web Pages. DataCeutics, Inc., Pottstown, PA

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

Using DS2TREE Macro to Create Interactive Treeview Diagrams for Clinical Adverse Experiences Records

Using Proc Freq for Manageable Data Summarization

A Generalized Procedure to Create SAS /Graph Error Bar Plots

Get into the Groove with %SYSFUNC: Generalizing SAS Macros with Conditionally Executed Code

Compute; Your Future with Proc Report

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

10 The First Steps 4 Chapter 2

Application of Modular Programming in Clinical Trial Environment Mirjana Stojanovic, CALGB - Statistical Center, DUMC, Durham, NC

Sorting big datasets. Do we really need it? Daniil Shliakhov, Experis Clinical, Kharkiv, Ukraine

Simple Rules to Remember When Working with Indexes

SAS seminar. The little SAS book Chapters 3 & 4. April 15, Åsa Klint. By LD Delwiche and SJ Slaughter. 3.1 Creating and Redefining variables

Using Templates Created by the SAS/STAT Procedures

My Reporting Requires a Full Staff Help!

Chapter 6 Creating Reports. Chapter Table of Contents

Report Writing, SAS/GRAPH Creation, and Output Verification using SAS/ASSIST Matthew J. Becker, ST TPROBE, inc., Ann Arbor, MI

9 Ways to Join Two Datasets David Franklin, Independent Consultant, New Hampshire, USA

Submitting SAS Code On The Side

An Introduction to Compressing Data Sets J. Meimei Ma, Quintiles

Tabulating Patients, Admissions and Length-of-Stay By Dx Category, Fiscal Year, County and Age Group

T.I.P.S. (Techniques and Information for Programming in SAS )

Transcription:

ABSTRACT Paper 236-28 An Automated Reporting Macro to Create Cell Index An Enhanced Revisit When generating tables from SAS PROC TABULATE or PROC REPORT to summarize data, sometimes it is necessary to produce a cell index as part of the data display. A cell index is simply a data listing that reports the summarized count of each cell shown in the table. This topic was presented and discussed at NESUG'01 Conference [7]. Several enhancements have since been made resulting in a major modification of the original code. It provides an automated SAS reporting macro to generate a cell index with several new features. The design goal for this program is to provide an efficient, flexible and easy-to-use macro. The SAS product used in this paper is SAS BASE, with no limitation of operating systems. Shi-Tao Yeh, GlaxoSmithKline, King of Prussia, PA The new and enhanced features are: num_var, freqsort, noprintv, and pageby. This paper provides a step-by-step approach to developing a SAS reporting module for cell index production. This paper is comprised of five parts. Part 1 includes the abstract and the introduction. Part 2 describes the sample data used throughout the paper. Part 3 is devoted to the program design and SAS code. Part 4 involves the SAS macro invocation and application. Part 5 concludes the paper. SAS MACRO DESIGN SPECIFICATION FOR CELL INDEX INTRODUCTION SAS System provides several useful tools for the production of tables and tabulations that summarize data. The procedures, PROC REPORT, and PROC TABULATE are very popular. It is sometimes required to generate a cell index as part of the data display after producing a summarized table. The clinical study reviewer or SAS programmer uses a cell index for program validation purposes. The difference between a data listing and a cell index is that a cell index displays only categorical variables that appear in the table. It displays data observations to support the summary count shown in each cell of the table. The last column of a cell index usually displays the subject variable. It is also a preferred design to have the column before the last as a numeric count of the sub-categorical grouping of the subject variable. The features and macro arguments of this macro are: FEATURE dsin sortby idvar num_var freqsort noprintv pageby DESCRIPTION a dataset name from which the cell index is to be produced a categorical variable list that appeared in the table a subject variable name a variable that provides additional information for the cell index a variable name that is used for descending sort order a dummy variable that provides the correct sort order but not showing on cell index output a variable list for output separated by page by variable list The program requirements for this macro are efficient, flexible and easy-to-use. This design goal can be achieved by minimizing the macro arguments. The framework of the program flow is described as follows The main code consists of six steps: STEP 1: This step accepts the user's input macro argument information and prepares the dataset for the cell index output. There are seven macro arguments, namely, dsin, sortby, num_var, freqsort, noprintv, and idvar. STEP 2: This step performs three counts: one for number of variables in the sortby list, the other for number of subject observations in each sub-category grouping, the last one for the space width available for listing of all variables in the sortby list. STEP 3: This step performs specific features for variables freqsort, noprintv, pageby and num_var. STEP 4: This step creates all SAS statements related to the procedure PROC REPORT. Then the SAS macro statements create a temporary SAS macro file named ctemp.sas. STEP 5: SAS file ctemp.sas is run to create a cell index. 1

STEP 6: All data files and temporary SAS macro files are deleted after the execution of the SAS macro get_cell.sas. Note: The X statement used in this program is for the UNIX platform. You need to issue your operating system command to delete the temporary file ctemp.sas Note: The statement %let dwidth=%eval(%eval(94/%eval(&j- 1))); is for reserved space width for all sortby variables. You can make further adjustments to fit your needs. SAS CODE FOR CELL INDEX The whole SAS macro code are shown as follows: %macro get_cell(dsin=, sortby=, idvar=, num_var=, freqsort=n, noprintv=, pageby=); * read in dataset ; set &dsin; count=1; proc sort; by &sortby; %if &pageby ne %then %do; proc sort data=dsin nodupkey; by &pageby &sortby &idvar; * using &sortby for grouping to count number of * objects in each cell proc summary data= dsin; by &pageby &sortby; var count; output out=pxyz1 sum=n; merge dsin pxyz1; by &pageby &sortby; %if %upcase(&freqsort) eq Y %then %do; proc sort data=dsin;by descending n ; data dsinn(keep=orderv n); set dsin; length orderv $5.; orderv = substr(left(_n_),1,5); proc sort data=dsin;by n; proc sort data=dsinn nodupkey;by n; merge dsin dsinn;; by n; %if %upcase(&pageby) ne %then %do; proc sort data=dsin;by &pageby; * count number of variables in &sortby list %macro varn; %local j; %let j=1; %let varn=%scan(&sortby,&j); %do %while ("&varn" ne ""); %let j=%eval(&j+1); %let varn=%scan(&sortby,&j); %global sortbyn dwidth; %let sortbyn=%eval(&j-1); %if &num_var ne %then %do; %let dwidth=%eval(%eval(81/%eval(&j-1))); %let dwidth=%eval(%eval(81/%eval(&j- 2))); %else %do; %let dwidth=%eval(%eval(93/%eval(&j-1))); %let dwidth=%eval(%eval(93/%eval(&j- 2))); %mend varn; %varn; * covert &sortby list to a column that contains * each variable in &sortby list * as a record with one &sortby variable data f1; length &sortby 4.; %do i=1 %to &sortbyn; %scan(&sortby,&i)=1; proc transpose data=f1 out=f2(keep=_name_); var &sortby; data f2; set f2; if _name_ = "%upcase(&noprintv)" then delete; * The following 3 datasets f1, f2, and f3, * construct a temp SAS macro to perform * proc report and produce a cell index by * constructing a dataset with define statement * for &sortby argument data f2; set f2 end=eof; var1 = 'define ' _name_ " / order left width=&dwidth flow ; "; if eof then do; var1 = 'define ' "&noprintv" " / order noprint ; "; end; * construct a dataset with define statement for 2

* variable n and &idvar; data f3; length var1 $90.; var1='define n / order width=5 "N";'; var1="define &idvar / display width=15 flow ;"; %if &num_var ne %then %do; var1="define &num_var / display right width=13 ;"; var1="break after %scan(&sortby, &sortbyn ) /skip;"; var1=''; var1=' %mend ctemp; '; * construct a dataset with macro statement and * proc report statement data f1; length var1 $90.; var1=' %macro ctemp; '; var1="proc report data=dsin headline headskip split='~';"; %if %upcase(&pageby) ne %then %do; var1="by &pageby;"; %if %upcase(&freqsort) eq Y %then %do; var1="column ('==' orderv &sortby n &num_var &idvar);"; var1="define orderv / order noprint ;"; %else %if %upcase(&freqsort) ^= Y %then %do; var1="column ('==' &sortby n &num_var &idvar);"; data f2(keep=var1); set f1 f2 f3; * macro call ctemp.sas to produce cell index data _null_; set f2; file 'ctemp.sas'; put var1; %inc 'ctemp.sas'; %ctemp; * remove temp SAS macro ctemp.sas and clean up * datasets x 'rm ctemp.sas'; proc datasets nolist; delete pxyz1 f1 f2 f3 dsin dsinn; %mend get_cell; SAS MACRO INVOCATION AND APPLICATION Before this macro invocation, it is important that you use the DATA STEP to prepare the SAS data set and label for variables to appeare in the cell index. In this section, individual an invocation example with code and a figure showing the relationship between table and cell index are provided. The sample macro invocation example 1 is as follows: sortby = trt agec sex, Note: This macro accepts categorical variables in the sortby argument. If you have numeric variables in the sortby list, you need to convert them to character variables before invocating the macro. A summary table displays the treatment variable as the across variable with categorical variables of age group and sex. The output of summary table and cell index from this example 1 is shown in Figure 1. Figure 1 Output of Summary Table and Cell Index from Example 1 Example 2 uses the feature num_var, to add additional variable to the cell index, either numeric or character variable, and specifies it as age. The output from this example is shown in Figure 2. 3

idvar = pid); sortby = trt agec sex, num_var = age, Figure 2 Cell Index with Additional Variable num_var Specified Figure 3 Cell Index with noprintv Specified Sometimes the output table contains a certain sort order for the key variable. It is desired that the cell index contains the sort order for the same variable. You can create a 'no print' variable that controls the desired sort order without printing it on the output. Example 3 is a sample of this type of output. sortby = trt_o trt agec sex, num_var = age, noprintv = trt_o, Sometimes the output table program contains a by statement that output is breaking by this 'pageby' variable. It is desired that the cell index contains the same feature to break the output by 'pageby' variable.. Example 4 is a sample of this type of output. %get_cell(dsin = lab, sortby = visit range, num_var = labhl, pageby = labtest trt, Figure 4. Cell Index with pageby Specified 4

Sometimes the output table contains a certain descending sort order for the key variable. It is desired that the cell index contains the descending sort order for the frequency count N. Example 5 is a sample of this type of output. %get_cell(dsin = aesub, sortby = pref trt, freqsort = Y, idvar = pid); * Provides a compact, efficient, and simple code for cell index production. ACKNOWLEGMENTS The author would like to thank Ellen Forman, Shu-Mei Huang, Biostatistics & Data Management, GlaxoSmithKline, and Ju Zhang from EDP Contract Services, for their review, validation and enhancement suggestions of this macro. REFERENCES [1] Alissa S. Bernholc: "A Tip for Using the Tabulate Procedure: Generating Tables with Percentages in Only One Category" Observations, online article, June1998, SAS Institute Inc., Cary, NC, USA [2] Stephen M. Noga, Jeffery M. Abolafia: "The Tabulate Procedure: One Step Beyond the Final Chapter" Proceedings of the Twenty-Third Annual SAS Users Group International Conference, pp. 839-844, March 1998 [3] Ron Coleman: "The Building Blocks of PROC TABULATE" Proceedings of the Twenty-Third Annual SAS Users Group International Conference, pp. 34-39, March 1998 [4] Dan Bruns: "The Utter Simplicity of the TABULATE Procedure The Final Chapter", Proceedings of the Sixteenth Annual SAS Users Group International Conference. 1997 [5] Dan Bruns: "The Utter Simplicity of the TABULATE Procedure The Sequel", Proceedings of the Sixteenth Annual SAS Users Group International Conference. 1996 [6] Shi-Tao Yeh ; SAS Macros for Grouping Count and Its Application to Enhance Your Reports, NESUG '99 Annual Conference Proceedings, pp. 583-587, October 1999 CONCLUSION This paper takes a comprehensive approach in designing a reporting module for creation of a cell index. SAS code and the examples of how to invocate the SAS macro are provided in this paper. This paper achieves the following goals: * Provides an easy-to-use macro with only seven macro arguments * Provides enhanced features to fit the different needs [7] "An Automated Reporting Macro to Create Cell Index, NESUG 2001 Annual Conference Proceedings, pp. 711-715, September, 2001 SAS is a registered trademark of SAS Institute Inc., Cary, NC, USA indicates USA registration. Author Shi-Tao Yeh, Ph. D. (610)917-5883(W) E-mail: shi-tao_yeh-1@gsk.com 5