SAS PROC REPORT PROC TABULATE

Slides:



Advertisements
Similar presentations
The Power of Proc Tabulate Part 1: The Basics David M. Rivard.
Advertisements

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth.
Exploring Microsoft Access
Computing for Research I Spring 2011 January 19, 2011
Intro to Excel - Session 5.31 Tutorial 5 - Session 5.3 Working with Excel Lists.
Quick Data Summaries in SAS Start by bringing in data –Use permanent data set for these examples Proc Tabulate –Produces summaries very quickly and easily.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Basic And Advanced SAS Programming
 Avoid repetitious SAS code  Create generalizable and flexible SAS code  Pass information from one part of a SAS job to another  Conditionally execute.
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Chapter 8 Producing Summary Reports. Section 8.1 Introduction to Summary Reports.
1 Chapter 5: Creating Summarized Output 5.1 Generating Summary Statistics 5.2 Creating a Summary Report with the Summary Tables Task 5.3 Creating and Applying.
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
PROC REPORT organizes the output in many ways, from the simple to highly complex… PROC REPORT NOWINDOWS HEADLINE HEADSKIP; COLUMN variable-list; DEFINE.
October 2003Bent Thomsen - FIT 3-21 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
USING SAS PROCEDURES SAS System Options OPTIONS Statement
1 Data List Spreadsheets or simple databases - a different use of Spreadsheets Bent Thomsen.
XP 1 Excel Tables Purpose of tables – Process data in a group – Used to facilitate calculations – Used to enhance readability of output Types of tables.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Knowing Understanding the Basics Writing your own code SAS Lab.
Using the new Version 8 Template Procedure for Complete Control of SAS Output Style and Format David Ghan Technical Training Specialist SAS, Canada.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
Reports and Queries Chapter 3 – Access text Reports – Page Queries – Page
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
XP. Objectives Sort data and filter data Summarize an Excel table Insert subtotals into a range of data Outline buttons to show or hide details Create.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
Intro to Excel - Session 5.21 Tutorial 5 - Session 5.2 Working with Excel Lists.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Working with Data Lists.
1 EPIB 698C Lecture 4 Raul Cruz-Cano Summer 2012.
Lesson 8 - Topics Creating SAS datasets from procedures Using ODS and data steps to make reports Using PROC RANK Programs in course notes LSB 4:11;5:3.
An Introduction Katherine Nicholas & Liqiong Fan.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
Chapter 6 Concatenating SAS Data Sets and Creating Summary Reports Xiaogang Su Department of Statistics University of Central Florida.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Task Dialogs 3.2 Creating a Listing Report 3.3 Creating a Frequency Report 3.4 Creating a Two-Way.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
Patrick Thornton SRI International.  Example of a Multiple Response Item ◦ Variable coding and example data  A Cross Tabulation using Proc REPORT 
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
1 Checking Data with the PRINT and FREQ Procedures.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
The Urban Institute - SAS Training6/9/20161 SAS Training This SAS Training Course was designed to introduce users at The Urban Institute to SAS programming.
1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Session 1 Retrieving Data From a Single Table
Applied Business Forecasting and Regression Analysis
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Instructor: Raul Cruz-Cano
Lesson 8 - Topics Creating SAS datasets from procedures
Tamara Arenovich Tony Panzarella
Chapter 4: Sorting, Printing, Summarizing
Quick Data Summaries in SAS
Producing Descriptive Statistics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Presentation transcript:

SAS PROC REPORT PROC TABULATE Computing for Research I January 27, 2014

PROC REPORT

Proc Report Intro Similar to Proc Print, with more control over output appearance and format Produces detail reports (data listings) and summary reports

Proc Report Syntax Basics PROC REPORT data=dataset <options>; COLUMN var1 var2 var3; DEFINE var1 / <options>; DEFINE var2 / <options>; RUN;

Proc Report Statement DATA= input data set NOWD/NOWINDOWS Option - non-interactive mode Additional Options - control layout of the report COLWIDTH= MISSING SPLIT=‘character’ SPANROWS (for ODS only) STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]> (for ODS only) SPANROWS - specifies that a single cell will occupy the column in all the rows for which the value is the same. Only applies to ODS MARKUP, PDF, RTF, and PRINTER destinations. STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]>specifies one or more style elements (for the Output Delivery System) to use for different parts of the report. COLWIDTH=column-width - specifies the default number of characters for columns containing computed variables or numeric data set variables. MISSING - considers missing values as valid values for group, order, or across variables. SPLIT='character‘ - specifies the split character.

Other Statements Column Statement - describes the arrangement of columns and column headers that span >1 column Define Statement Variable Appearance (format, label, justify) Variable Usage DISPLAY – default for character variables ANALYSIS – default for numeric variables ORDER – determines row order ORDER=FORMATTED | INTERNAL | DATA | FREQ GROUP – consolidates unique values of GROUP variables into one row Rbreak Statement - produces a default summary at the beginning or end of a report or at the beginning or end of each BY group.

Vital Signs Dataset SubjectID (47 subjects) VisitID (1-16), Visit Nm (Baseline, Day 1 – Day 15) SBP, DBP, Heart Rate, Central Venous Pressure 1 record per subject per visit

Proc Report Code: Example 1 title 'Baseline and Day 1 Blood Pressure' ; proc report data=vitals nowd split='*'; where visitid in (1,2) and 1020 le subjectid le 1029; columns subjectid visitnm ('Blood*Pressure' SBP DBP); define subjectid / 'Subject' order; define visitnm / 'Visit' ; define SBP / 'Systolic' format=8. center; define DBP / 'Diastolic' format=8. center; run;

Proc Report Output: Example 1 Baseline and Day 1 Blood Pressure   Blood Pressure Subject Visit Systolic Diastolic 1020 Baseline 160 80 Day 1 1021 145 100 151 70 1022 195 105 85 1023 135 75 158 94 1024 186 1025 146 82 1026 155 165 1027 134 1028 178 83 86 1029 180

Proc Print Comparison: Example 1 SubjectID VisitNm Systolic Blood Pressure Diastolic Blood Pressure 1020 Baseline 160 80 Day 1 1021 145 100 151 70 1022 195 105 85 1023 135 75 158 94 1024 186 1025 146 82 1026 155 165 1027 134 1028 178 83 86 1029 180 proc sort data=vitals; by subjectid; run; proc print data=vitals label noobs; where visitid in (1,2) and 1020 le subjectid le 1029; var subjectid visitnm SBP DBP;

Proc Report Code: Example 2 ods rtf; title 'Average Blood Pressure by Visit'; proc report data=vitals nowd split='*' style(header)=[fontsize=14pt textalign=center foreground=white background=black]; columns visitnm ('Average*Blood Pressure' SBP DBP); define visitnm / 'Visit' group order=data; define SBP / 'Systolic' format=8. center mean; define DBP / 'Diastolic' format=8. center mean; rbreak after /summarize; run; ods rtf close;

Proc Report Output: Example 2 Average Blood Pressure by Visit   Average Blood Pressure Visit Systolic Diastolic Baseline 159 81 Day 1 163 83 Day 2 169 87 Day 3 170 89 Day 4 91 Day 5 174 Day 6 173 Day 7 90 Day 8 Day 9 Day 10 88 Day 11 166 Day 12 Day 13 168 Day 14 161 Day 15 86

Proc Means Comparison: Example 2 ods rtf; title 'Average Blood Pressure by Visit'; proc means data=vitals mean; class visitnm; var SBP DBP; run; ods rtf close; VisitNm N Obs Variable Label Mean Baseline 47 SBP DBP Systolic Blood Pressure Diastolic Blood Pressure 158.9361702 80.5744681 Day 1 46 162.7826087 83.3043478 Day 10 36 169.8888889 88.3888889 Day 11 33 166.3030303 91.0000000 Day 12 26 170.2692308 91.0384615 Day 13 167.8461538 89.5769231 Day 14 24 161.4166667 89.0833333 Day 15 19 158.7368421 85.6315789 Day 2 168.5744681 87.4680851 …

Proc Report Resources SAS Documentation Learning Proc Report http://www2.sas.com/proceedings/forum2008/170-2008.pdf Proc Report Advanced Tutorial http://www2.sas.com/proceedings/sugi28/015-28.pdf

PROC TABULATE

Proc Tabulate Intro Similar to Proc Means and Proc Freq, in tabular format Creates summary reports with descriptive statistics

Proc Tabulate Syntax Basics PROC TABULATE data=dataset; CLASS classification variables; VAR analysis variables; TABLE page dimension, row dimension, column dimension / <options>; RUN; Depending on the variables you are looking at, the ‘class’ and ‘var’ statements will be required (at least one is required). Var statement used to analyze numeric variables.

Class and Var Statements Class Statement identifies the class variables (character or numeric) determines the categories that Proc Tabulate uses to calculate statistics Missing Option - if not included, observations with any missing class variable values are excluded from the table Var Statement Identifies numeric variables to use as analysis variables.

Table Statement Required for procedure Describes the table to create Format: page variables, row variables, column variables Can include variable names, keyword statistics, and operators Options PRINTMISS MISSTEXT= BOX=

Table Statement Operators Comma – starts a new dimension Blank – concatenates elements Asterisk – creates categories from the combination of values of the class variables and calculates appropriate statistics if class and analysis variables are crossed Parentheses – groups elements, associates operator with each element in the group

Table Statement Statistic Keywords N NMISS PCTN COLPCTN ROWPCTN MEAN STD MIN MAX MEDIAN Q1 Q3 many more…

Other Statements KEYLABEL – labels a statistic keyword KEYWORD – specifies a style element for keyword headings CLASSLEV – specifies a style element for class variable level value headings

Proc Tabulate Code: Example 1 proc tabulate data=vitals; where visitid in (1,2) and 1020 le subjectid le 1029; class subjectid visitnm; table all subjectid, (visitnm='Visits')*(n pctn='%') / box=[label='Subjects x Visits'] misstext='MISSING' printmiss; run;

Proc Tabulate Output: Example 1 Subjects x Visits Visits Baseline Day 1 N % All 10 52.63 9 47.37 SubjectID 1 5.26 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 MISSING 0.00

Example 1: Proc Freq Comparison proc freq data=vitals; where visitid in (1,2) and 1020 le subjectid le 1029; table subjectid*visitnm /norow nocol; run; Table of SubjectID by VisitNm SubjectID(SubjectID) VisitNm(VisitNm) Frequency Percent Baseline Day 1 Total 1020 1 5.26 2 10.53 1021 1022 1023 1024 1025 1026 1027 1028 1029 0 0.00 10 52.63 9 47.37 19 100.00

Proc Tabulate Code: Example 2 title 'Average Blood Pressure Across Baseline and Day 1'; proc tabulate data=vitals; where visitid in (1,2) and 1020 le subjectid le 1029; class subjectid ; var SBP DBP; table all subjectid, (SBP DBP)*(n mean*f=8.1 std*f=8.1); keylabel std='SD'; run;

Proc Tabulate Output: Example 2 Average Blood Pressure Across Baseline and Day 1   Systolic Blood Pressure Diastolic Blood Pressure N Mean SD All 19 158.9 18.6 83.6 8.3 SubjectID 2 160.0 0.0 80.0 1020 1021 148.0 4.2 85.0 21.2 1022 170.0 35.4 95.0 14.1 1023 146.5 16.3 84.5 13.4 1024 186.0 1025 146.0 82.0 1026 7.1 1027 134.0 81.0 1.4 1028 169.0 12.7 2.1 1029 1 180.0 . 75.0

Example 2: Proc Means Comparison proc means data=vitals mean std; where visitid in (1,2) and 1020 le subjectid le 1029; class subjectid; var SBP DBP; run; SubjectID N Obs Variable Label Mean Std Dev 1020 2 SBP DBP Systolic Blood Pressure Diastolic Blood Pressure 160.0000000 80.0000000 0 0 1021 148.0000000 85.0000000 4.2426407 21.2132034 1022 170.0000000 95.0000000 35.3553391 14.1421356 1023 146.5000000 84.5000000 16.2634560 13.4350288 1024 186.0000000 80.0000000 1025 146.0000000 82.0000000 1026 160.0000000 85.0000000 7.0710678 0 1027 134.0000000 81.0000000 0 1.4142136 1028 169.0000000 84.5000000 12.7279221 2.1213203 1029 1 180.0000000 75.0000000 . .

Proc Tabulate Resources SAS Documentation Proc Tabulate Introduction http://www.sascommunity.org/mwiki/images/4/49/Proc_Tabulate_how_to_-_version_2.0.pdf Using Style Elements in the REPORT and TABULATE Procedures http://support.sas.com/resources/papers/stylesinprocs.pdf

Reporting Data Plan the layout Use a report writing tool Summary statistics, analysis output or data listings? Content of columns/rows? Order of columns/rows? Font Use a report writing tool

QUESTIONS?