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

Similar documents
Setting the Percentage in PROC TABULATE

Remove this where. statement to produce the. report on the right with all 4 regions. Retain this where. statement to produce the

3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200;

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

Using Proc Freq for Manageable Data Summarization

Christopher Toppe, Ph.D. Computer Sciences Corporation

SAS - By Group Processing umanitoba.ca/centres/mchp

2. Don t forget semicolons and RUN statements The two most common programming errors.

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

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

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

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

Using PROC SQL to Calculate FIRSTOBS David C. Tabano, Kaiser Permanente, Denver, CO

Introduction to Stata Toy Program #1 Basic Descriptives

22S:166. Checking Values of Numeric Variables

EXAMPLE 2: INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT

SAS Programs SAS Lecture 4 Procedures. Aidan McDermott, April 18, Outline. Internal SAS formats. SAS Formats

A Cross-national Comparison Using Stacked Data

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

Table of Contents. The RETAIN Statement. The LAG and DIF Functions. FIRST. and LAST. Temporary Variables. List of Programs.

I Launching and Exiting Stata. Stata will ask you if you would like to check for updates. Update now or later, your choice.

DSCI 325: Handout 9 Sorting and Options for Printing Data in SAS Spring 2017

TYPES OF VARIABLES, STRUCTURE OF DATASETS, AND BASIC STATA LAYOUT

Validation Summary using SYSINFO

Introduction to SAS Mike Zdeb ( , #1

SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority

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

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

SAS Training Spring 2006

Introduction to SAS Mike Zdeb ( , #61

EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT)

Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury

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

BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA

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

Part B. EpiData Analysis

Getting it Done with PROC TABULATE

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes

ZIPpy Safe Harbor De-Identification Macros

Integrated MS-DRG Grouper & Calculator Printable How To Guide

Using PROC SQL to Generate Shift Tables More Efficiently

POLICY. Create a governance process to manage requests to extract de- identified data from the Information Exchange (IE).

Clean Claim Edits UB04

EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT)

Maintaining Formats when Exporting Data from SAS into Microsoft Excel

Producing Summary Tables in SAS Enterprise Guide

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

Stata version 13. First Session. January I- Launching and Exiting Stata Launching Stata Exiting Stata..

PharmaSUG Paper AD06

Chapter 3: Working With Your Data

Select the desired program, then the report and click the View Report button. The FSS Dashboard will appear as 87 NJ2024_FSS_DB_MenuPage.

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C.

0.1 Stata Program 50 /********-*********-*********-*********-*********-*********-*********/ 31 /* Obtain Data - Populate Source Folder */

A SAS Macro for Balancing a Weighted Sample

Format-o-matic: Using Formats To Merge Data From Multiple Sources

Open Problem for SUAVe User Group Meeting, November 26, 2013 (UVic)

Chaining Logic in One Data Step Libing Shi, Ginny Rego Blue Cross Blue Shield of Massachusetts, Boston, MA

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

This document contains confidential information that is proprietary to SonoSite. Neither the document nor the information contained therein should be

Create a SAS Program to create the following files from the PREC2 sas data set created in LAB2.

Intermediate SAS: Statistics

Introduction to STATA

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

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

Week 1: Introduction to Stata

Group Administrator. ebills csv file formatting by class level. User Guide

CIGNA Encounter Error Correction. Web-based Portal Training Prnlink.com, INC

GETTING DATA INTO THE PROGRAM

Unit-of-Analysis Programming Vanessa Hayden, Fidelity Investments, Boston, MA

Opening a Data File in SPSS. Defining Variables in SPSS

Excel Introduction to Excel Databases & Data Tables

%ANYTL: A Versatile Table/Listing Macro

Contents of SAS Programming Techniques

Local Lab Normal Range Management Tool (LNMT) Site Job Aid for Late Stage Development

Common File System Commands

Overview of Data Management Tasks (command file=datamgt.sas)

PROC SUMMARY AND PROC FORMAT: A WINNING COMBINATION

Multivariate probability distributions

ssh tap sas913 sas

SD10 A SAS MACRO FOR PERFORMING BACKWARD SELECTION IN PROC SURVEYREG

Automating Descriptive Statistics

Introduction (SPSS) Opening SPSS Start All Programs SPSS Inc SPSS 21. SPSS Menus

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

Bar Charts and Frequency Distributions

April 4, SAS General Introduction

PROC FORMAT. CMS SAS User Group Conference October 31, 2007 Dan Waldo

Creating New Variables in JMP Datasets Using Formulas Exercises

INTRODUCTION to SAS STATISTICAL PACKAGE LAB 3

Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC

Paper SAS Programming Conventions Lois Levin, Independent Consultant, Bethesda, Maryland

SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Module 2

Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio

NPDA User Guide: Submitting your data via CSV

ERROR: ERROR: ERROR:

What you learned so far. Loops & Arrays efficiency for statements while statements. Assignment Plan. Required Reading. Objective 2/3/2018

SAS Programming Conventions Lois Levin, Independent Consultant

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

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

WHO Child Growth Standards SPSS Syntax File (igrowup_dhsind.sps)

A Side of Hash for You To Dig Into

Transcription:

Tabulating Patients, Admissions and Length-of-Stay By Dx Category, Fiscal Year, County and Age Group Step One: Extracting Data Use an array in a data step to search all the Dx Codes in one pass. The array creates a variable with n levels so you can search through a list of different variables with one command. data dataset1; set datalib.phrudata; length flag1 flag2 $ 1; Write extracted data to dataset1 Read data from datalib.phrudata Initialize flags for each relevant Dx Category flag1 = ; flag2 = ; array name{n} var1-varn; do i = 1 to n; if name{i} = dxcode1 then flag1= 1 ; if name{i} = dxcode2 then flag2= 1 ; if flag1 ne or flag2 ne ; Define name, number of elements and variables in the array Loop through each element in the array Search the array for a particular Dx Code and flag records where it appears If you are searching for multiple Dx Codes, use multiple flags to avoid overwriting flags for other relevant Dx Codes on the same record End loop Keep flagged records Keep in mind that although you are searching through n variables, they are all on the same record. Also note that the flag will only tell you that the record contains at least one occurrence of the relevant Dx Code, not how many times that Dx Code appears on the record. Step Two: Creating Categorical Variables Age Group: proc format; value agegrpf 1= 00-04 2= 05-09 18-high= 85+ ; Create a format for the age groups to be defined later The 18-high statement means any value from 18 up The format procedure must immediately follow the libname statements and come before any other procedures or data steps

age=int((sepdate-dob)/365.25); agegrp=int((age/5) + 1); format agegrp agegrpf.; Age is not a reliable variable, and should be calculated from the date of birth and separation date fields This is a shortcut for calculating 5-year age groups. The number you divide by determines the groupings Format the agegrp variable with the agegrpf. format. Note the required period at the end of the format Step Three: Summarizing the Data To count unique patients per fiscal year and calculate the mean number of admissions or LOS per patient, it is necessary to do some preliminary preparation of the data. Essentially, rather than a dataset of all admissions, you end up with a summarized dataset of one record per patient per year with cumulative admissions and length-of-stay. proc sort; by msi fy; data file2; set file1; by msi fy; length patients admits totlos 3; if first.msi or first.fy then do; admits=1; totlos=los; else do; admits+1; totlos+los; if last.msi or last.fy; patients=1; Sort the data by patient and fiscal year Use the BY statement to set up the FIRST. and LAST. function* Define numeric variables If patient s first admission in FY Initialize cumulative admissions counter Initialize total LOS to LOS of first admission If subsequent admission in FY Add 1 to cumulative admissions counter Add LOS to cumulative LOS Keep last summary record for each FY Count unique patients * The FIRST. and LAST. function creates a marker on the first and last occurrences of each unique value of a variable. MSI Marker FY Marker 01 first 89 first 01 89 01 89 last 01 90 first 01 last 90 last 02 first 89 first 02 90 last 02 last 91 first, last 03 first, last 89 first, last

Step Four: Tabulating the Data There are two options for tabulating and outputting the data: the means procedure and the tabulate procedure. The Means procedure is straightforward, but is most useful when you have a limited number of dimensions you want to present. The Tabulate is more useful when you are trying to present data in several dimensions (eg. by procedures by year, sex, age group and county). This procedure usually requires a little trial-and-error programming but can usually produce decent results. Proc Means: proc means sum mean; Select the statistics you want proc means to present title1 Title of Table ; title2 Title Subheading ; class fy sex agegrp; var patients admits totlos; Use the CLASS statement to select the categories by which you want the data presented Specify which variables you want in the output. Using the data preparation outlined earlier, this procedure will present the number of unique patients (N & ΣPATIENTS), total and mean admissions per patient (ΣADMITS, MEAN ADMISSIONS) and total and mean length-of-stay per patient (Σ LOS, MEAN LOS). Disregard the mean patients statistic as it has no useful meaning. Proc Tabulate: proc tabulate; title1 Title of Table ; title2 Title Subheading ; class fy county sex agegrp; var patients admits totlos; tables fy*(county all), Define your categories Define your variables The TABLES statement defines the presentation of your data. The commas separate the dimensions of your tables. With 2 dimensions, comma separates the vertical from the horizontal dimension. With 3 dimensions, the first comma separates pages and the second comma separates vertical and horizontal dimensions on the page. This line will generate a tabulation with one page per fiscal year per county with the last page of each fy tabulating all counties for that fy.

(sex all= M&F )*(age all= All Ages ), patients*sum*f=comma8. admits*(sum*f=comma8. mean*f=8.2) totlos*(sum*f=comma8. mean*f=8.2) / box=_page_ RTS=50; This line generates the vertical dimension of the table, with sex by age group and a summary of all ages for each age group and combined sex by age group. Sum of patients in 8 column comma format Sum and mean admissions Sum and mean of total LOS per patient Places page heading in the left-hand corner of the table Optional. This controls the number of columns allocated to the vertical category titles. It usually requires a little trial and error to get it to look right. Proc Tabulate gives you much more control over how you want the data presented. This is particularly useful when you are trying to condense data into the fewest pages.

The Full Program: /* Program to extract Hypertension admissions from CIHI95 */ options ls=90 ps=78 SASAUTOS= macro library ; libname library [project directory] ; libname datalib [data directory] ; proc format; value agegrp 1= 00-04 /* Create age group format */ 2= 05-09 18-high= 85+ ; data hyper95; /* Write extracted data to hyper95 */ set datalib.cihi95; /* Read data from CIHI95 */ length flag1 flag2 $ 1; flag = ; /* Initialize Flag */ array dxcodes{10} dxcode1-dxcode10; /* Define array as dxcode1-10 */ do i = 1 to 10; /* Repeat loop 16 times */ if dxcodes{i} =: 401 then flag= 1 ; /* Flag records with 401 code */ /* End loop */ if flag = 1 ; /* Keep flagged records */ {Repeat this datastep for each year you are interested in} data combined; /* Combine data from all years */ set hyper95 hyper94 ; /* Read all hyper datasets */ proc sort; /* Note, Procedures default to last written dataset */ by msi fy; /* Sort data by MSI and FY */ continued

data sumhyper; set combined; by msi fy; /* Create FIRST. and LAST. identifiers for MSI & FY */ length patients admits totlos 3; /* Define numeric variables */ if first.msi or first.fy then do; /* Summarize admissions and LOS by FY */ admits=1; totlos=los; else do; admits+1; totlos+los; if last.msi or last.fy; /* Keep summary record */ patients=1; /* Count patients */ proc means sum mean; /* Output data with proc means */ title1 Hypertension Patients, Admissions & Length-of-Stay ; title2 by Fiscal Year, County, Sex & Age Group ; class fy sex agegrp; var patients admits totlos; proc tabulate; /* Output data with proc tabulate */ title1 Hypertension Patients, Admissions & Length-of-Stay ; title2 by Fiscal Year, County, Sex & Age Group ; class fy county sex agegrp; var patients admits los; tables fy*(county all), /* Page */ (sex all= M&F )*(age all= All Ages ), /* Vertical Dimension */ patients*sum*f=comma8. /* Horizontal Dimension */ admits*sum*f=comma8. totlos*(sum*f=comma8. mean*f=8.2) / box=_page_ RTS=50;