EPIB 698E Lecture 8 Raul Cruz-Cano Fall 2013. SAS ODS (Output Delivery System)

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
1 Business 90: Business Statistics Professor David Mease Sec 03, T R 7:30-8:45AM BBC 204 Lecture 5 = More of Chapter “Presenting Data in Tables and Charts”
Chapter 2 Graphs, Charts, and Tables – Describing Your Data
Business Statistics: A Decision-Making Approach, 7e © 2008 Prentice-Hall, Inc. Chap 2-1 Business Statistics: A Decision-Making Approach 7 th Edition Chapter.
Chapter 2 Graphs, Charts, and Tables – Describing Your Data
Statistics for Managers Using Microsoft Excel, 5e © 2008 Pearson Prentice-Hall, Inc.Chap 2-1 Statistics for Managers Using Microsoft® Excel 5th Edition.
Business 90: Business Statistics
SPSS Statistical Package for the Social Sciences is a statistical analysis and data management software package. SPSS can take data from almost any type.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Tasks and Wizards 3.2 Creating a Frequency Report 3.3 Generating HTML, PDF, and RTF Output.
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
The gchart Procedure The gchart Procedure is used to create bar charts of various types (it can also create pie charts. It’s most basic form would look.
How to build graphs, charts and plots. For Categorical data If the data is nominal, then: Few values: Pie Chart Many Values: Pareto Chart (order of bars.
Copyright © 2010, Meta-Xceed, Inc. All rights reserved. BI Flash and all other Meta-Xceed Inc. product or service names are registered trademarks or trademarks.
11 Chapter 3: Getting Started with Tasks 3.1 Introduction to Tasks and Wizards 3.2 Creating a Frequency Report 3.3 Generating HTML, PDF, and RTF Output.
Drill-down Graphs By Heather Hoffman. Family Practice Department Project  Create drill-down graphs that depict % of patients for each CCS* over a given.
SAS PROC REPORT PROC TABULATE
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Lecture 2 Graphs, Charts, and Tables Describing Your Data
EPIB 698D Lecture 2 Raul Cruz Spring SAS functions SAS has over 400 functions, with the following general form: Function-name (argument, argument,
Business Statistics: A Decision-Making Approach, 6e © 2005 Prentice-Hall, Inc. Chap 2-1 Business Statistics: A Decision-Making Approach 6 th Edition Chapter.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
SAS ODS (Output Delivery System) Donald Miller 812 Oswald Tower ;
Statistical Methods © 2004 Prentice-Hall, Inc. Week 2-1 Week 2 Presenting Data in Tables and Charts Statistical Methods.
Chap 2-1 A Course In Business Statistics, 4th © 2006 Prentice-Hall, Inc. A Course in Business Statistics 4 th Edition Chapter 2 Graphs, Charts, and Tables.
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.
1 EPIB 698C Lecture 4 Raul Cruz-Cano Summer 2012.
1. Tables, Charts, and Graphs Microsoft Word & Excel 2003.
Chapter 3: Organizing Data. Raw data is useless to us unless we can meaningfully organize and summarize it (descriptive statistics). Organization techniques.
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
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.
Android Online Training AcuteSoft: India: , Land Line: +91 (0) USA: , UK : +44.
Using SAS to Create Multi-Sheet Excel Workbooks
Chapter 3: Getting Started with Tasks
Chapter 5: Enhancing Your Output with ODS
Applied Business Forecasting and Regression Analysis
Lesson 4 Descriptive Procedures
Welcome to Week 02 Tues MAT135 Statistics
Excel Part 4 Working with Charts and Graphics
Displaying and Describing Categorical Data
Tutorial 4: Enhancing a Workbook with Charts and Graphs
Chapter 8: ODS Graphics ODS graphics were not available prior to SAS 9.2 They have been implemented across a wide range of procedures Functionality isn’t.
Excel Part 4 Working with Charts and Graphics
Instructor: Raul Cruz-Cano
Lesson 8 - Topics Creating SAS datasets from procedures
Tamara Arenovich Tony Panzarella
Chapter 4: Sorting, Printing, Summarizing
Chapter 2 Presenting Data in Tables and Charts
Outline READ DATA DATA STEPS MERGE DATA PROC IMPORT
Lecture 2 Topics - Descriptive Procedures
Graphs with SPSS.
Producing Descriptive Statistics
Week 3 Lecture Notes PSYC2021: Winter 2019.
Let’s continue to review some of the statistics you’ve learned in your first class: Bivariate analyses (two variables measured at a time on each observation)
Organizing, Displaying and Interpreting Data
Excel Part 4 Working with Charts and Graphics
Let’s review some of the statistics you’ve learned in your first class: Univariate analyses (single variable) are done both graphically and numerically.
Lecture 2 Topics - Descriptive Procedures
Presentation transcript:

EPIB 698E Lecture 8 Raul Cruz-Cano Fall 2013

SAS ODS (Output Delivery System)

ODS is a powerful tool that can enhance the efficiency of statistical reporting and meet the needs of the investigator. To create output objects that can be send to destinations such as HTML, PDF, RTF (rich text format), or SAS data sets. To eliminate the need for macros that used to convert standard SAS output to a Microsoft Word, or HTML document Create graphs that enhance the output provided by certain procedures

Fish Measurement Data (reminder) ods graphics on; title 'Fish Measurement Data'; proc corr data=fish1 nomiss plots=matrix(histogram); var Height Width Length3 Weight3; run; ods graphics off; data Fish1 (drop=HtPct WidthPct); title 'Fish Measurement Data'; input Weight Length3 HtPct WidthPct Weight3= Weight**(1/3); Height=HtPct*Length3/100; Width=WidthPct*Length3/100; datalines; ; run; The data set contains 35 fish from the species Bream caught in Finland's lake Laengelmavesi with the following measurements: Weight (in grams) Length3 (length from the nose to the end of its tail, in cm) HtPct (max height, as percentage of Length3) WidthPct (max width, as percentage of Length3)

Creating Excel Report There are several options: –PROC EXPORT : It’s the same as the point and click method but you can do it with code. –LIBNAME ENGINE LIBNAME engine is one of the newest methods to transfer information from SAS into Excel. Lets you use Excel as a SAS library. LIBNAME engine allows advanced customization of your output. It does not give full control of Excel Excel does not need to be installed on the machine running SAS. –EXCELXP TAGSET : ExcelXP tagset is an ODS (Output Delivery System) destination available in SAS version 9.1 that utilizes the Extensible Markup Language (XML). It can be downloaded from the SAS website. Using the ExcelXP Tagset is a powerful method to control formatting of a spreadsheet. ExcelXP tagset can be used to export the results of PROC REPORT, PROC TABULATE, or PROC PRINT. It can display multiple tables per worksheet as well as multiple worksheets.

ODS RTF Output (rich text file) ods rtf file='C:\freq.rtf'; proc freq data=blood; Table GENDER; RUN; ods rtf close; Rft file data blood; INFILE 'C:\blood.txt'; INPUT subjectID $ gender $ bloodtype $ age_group $ RBC WBC cholesterol; run;

ODS RTF Output (rich text file) ods rtf file='C:\freq.rtf '; proc freq data=blood; Table GENDER; RUN; ods rtf close; directory File name

Creating Excel Report DATA style; INFILE ‘C:\style.txt'; INPUT Name $ 1-21 style $ Origin $ 42; RUN; ods tagsets.excelxp file="C:\comparision.xls" style =statistical options( sheet_interval= 'none' suppress_bylines= 'n’ ); PROC PRINT DATA = style; WHERE style = 'Impressionism'; TITLE 'Major Impressionist Painters'; FOOTNOTE 'F = France N = Netherlands U = US'; RUN; ods tagsets.excelxp close ;

(2) Or send to output file, then use PROC PRINT proc means data = blood; var RBC WBC cholesterol; output out = results; run; data results; set results (keep = _STAT_ RBC WBC cholesterol); if _STAT_ = "STD" then delete; run; ods tagsets.excelxp file = 'C:\Users\sphcart\Documents\EPIB698E\print_test.xls'; proc print data = results; title 'blood results'; footnote; run; ods tagsets.excelxp close; (1) Try the PROC anyway ods tagsets.excelxp file = 'C:\Users\sphcart\Documents\EPIB698E\results_proc_mean.xls‘ style=statistical; options( sheet_interval='none' suppress_bylines='n'); proc freq data=Color; tables Eyes Hair Eyes*Hair / out=FreqCount; weight Count; title 'Eye and Hair Color of European Children'; run; ods tagsets.excelxp close ; Creating Excel Report for PROC that by default can’t be used in the ODS (2) Might require a little research (not all PROCs use the same way to send to their output to a datatset)… title 'Correlations for a Fitness and Exercise Study'; proc corr data=Fitness nomiss outp=CorrOutp; var weight oxygen runtime; run; title 'Output Data Set from PROC CORR'; proc print data=CorrOutp noobs; run;

Outline Procedure syntax –PROC GCHART –PROC GPLOT Examples

Proc GCHART for bar charts Example: A bar chart showing the distribution of blood types from the Blood data set DATA blood; INFILE ‘C:\blood.txt'; INPUT ID Sex $ BloodType $ AgeGroup $ RBC WBC chol; run; title "Distribution of Blood Types"; proc gchart data=blood; vbar BloodType; run;

Proc GCHART for bar charts VBAR: request a vertical bar chart for the variable Alternatives to VBAR are as follows: HBAR: horizontal bar chart VBAR3D: three-dimensional vertical bar chart HBAR3D: three-dimensional horizontal bar chart PIE: pie chart PIE3D: three-dimensional pie chart DONUT: donut chart

A Few Options proc gchart data=blood; vbar bloodtype/space=0 type=percent ; run; Controls spacing between bars Changes the statistic from frequency to percent

Type option Type =freq : displays frequencies of a categorical variable Type =pct (Percent): displays percent of a categorical variable Type =cfreq : displays cumulative frequencies of a categorical variable Type =cpct (cPercent): displays cumulative percent of a categorical variable

Basic Output This value of 7,000 corresponds to a class ranging from 6500 to 7500 (with a frequency of about 350) SAS computes midpoints of each bar automatically. You can change it by supplying your own midpoints: vbar RBC / midpoints=4000 to by 1000;

Creating charts with values representing categories SAS places continuous variables into groups before generating a frequency bar chart If you want to treat the values as discrete categories, you can use DISCRETE option Example: create bar chart showing the frequencies by day of the week for the visit to a hospital

libname d “C:\”; data day_of_week; set d.hosp; Day = weekday(AdmitDate); run; *Program Demonstrating the DISCRETE option of PROC GCHART; title "Visits by Month of the Year"; proc gchart data=day_of_week; vbar Day / discrete; run;

The Discrete Option proc gchart data= day_of_week; vbar day /discrete; run; quit; Discrete establishes each distinct value of the midpoint variable as a midpoint on the graph. If the variable is formatted, the formatted values are used for the construction. If you use discrete with a numeric variable you should: 1. Be sure it has only a few distinct values. or 2. Use a format to make categories for it.

GPLOT The GPLOT procedure plots the values of two or more variables on a set of coordinate axes (X and Y). The procedure produces a variety of two- dimensional graphs including –simple scatter plots –overlay plots in which multiple sets of data points display on one set of axes

Procedure Syntax: PROC GPLOT PROC GPLOT; PLOT y*x ; run; Example: plot of systolic blood pressure (SBP) by diastolic blood pressure (DBP) title "Scatter Plot of SBP by DBP"; proc gplot data=d.clinic; plot SBP * DBP; run;

*controlling the axis ranges; title "Scatter Plot of SBP by DBP"; proc gplot data=d.clinic; plot SBP * DBP / haxis=70 to 120 by 5 vaxis=100 to 220 by 10; Run;

Multiple plots can be made in 3 ways: (1)proc gplot; plot y1*x y2*x /overlay; run; plots y1 versus x and y2 versus x using the same horizontal and vertical axes. (2) proc gplot; plot y1*x; plot2 y2*x; run; plots y1 versus x and y2 versus x using different vertical axes. The second vertical axes appears on the right hand side of the graph. (3) proc gplot ; plot y1*x=z; run; uses z as a classification variable and will produce a single graph plotting y1 against x for each value of the variable z.

Using the AXIS Statement AXIS statements can be defined anywhere in your SAS program. They are global and remain in effect until redefined, canceled, or until the end of your SAS session. AXIS statements are not applied automatically, and must be explicitly assigned by an option in the procedure that uses them. Proc GCHART RAXIS= /* response axis */ MAXIS= /* midpoint axis */ GPLOT HAXIS= /*horizontal axis*/ VAXIS= /* vertical axis */

*controlling the axis ranges; title "Scatter Plot of SBP by DBP"; proc gplot data=d.clinic; plot SBP * DBP / haxis=70 to 120 by 5 vaxis=100 to 220 by 10; run;

axis1 order=('North' 'South' 'East' 'West') label=('region of the country') length=30; axis2 label=('sum of the total sales') length=30; proc gchart data=d.sales; vbar Region / sumvar=TotalSales type=sum maxis=axis1 raxis=axis2; format TotalSales dollar8.; Run; sumvar= summary variable