Presentation is loading. Please wait.

Presentation is loading. Please wait.

SAS PROC REPORT PROC TABULATE

Similar presentations


Presentation on theme: "SAS PROC REPORT PROC TABULATE"— Presentation transcript:

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

2 PROC REPORT

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

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

5 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.

6 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.

7 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

8 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;

9 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

10 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 le subjectid le 1029; var subjectid visitnm SBP DBP;

11 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;

12 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

13 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 Day 1 46 Day 10 36 Day 11 33 Day 12 26 Day 13 Day 14 24 Day 15 19 Day 2

14 Proc Report Resources SAS Documentation Learning Proc Report
Proc Report Advanced Tutorial

15 PROC TABULATE

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

17 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.

18 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.

19 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=

20 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

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

22 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

23 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;

24 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

25 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 1021 1022 1023 1024 1025 1026 1027 1028 1029

26 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;

27 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

28 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 0 0 1021 1022 1023 1024 1025 1026 1027 1028 1029 1 . .

29 Proc Tabulate Resources
SAS Documentation Proc Tabulate Introduction Using Style Elements in the REPORT and TABULATE Procedures

30 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

31 QUESTIONS?


Download ppt "SAS PROC REPORT PROC TABULATE"

Similar presentations


Ads by Google