1 / 20

EPIB 698C Lecture 5

EPIB 698C Lecture 5. Raul Cruz-Cano. 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' ;

nevina
Télécharger la présentation

EPIB 698C Lecture 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EPIB 698C Lecture 5 Raul Cruz-Cano

  2. Outline • Procedure syntax • PROC GCHART • PROC GPLOT • Examples

  3. 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"; procgchartdata=blood; vbar BloodType; run; quit;

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

  5. A Few Options procgchartdata=blood; vbar bloodtype/space=0type=percent ; run; quit; Controls spacing between bars Changes the statistic from frequency to percent

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

  7. 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 11000 by 1000;

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

  9. libname d “C:\”; dataday_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; quit;

  10. The Discrete Option procgchartdata= 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.

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

  12. Procedure Syntax: PROC GPLOT • PROC GPLOT; PLOT y*x </option(s)>; run; • Example: plot of systolic blood pressure (SBP) by diastolic blood pressure (DBP) title"Scatter Plot of SBP by DBP"; procgplotdata=d.clinic; plot SBP * DBP; run;

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

  14. Multiple plots can be made in 3 ways: • 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.

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

  16. SAS ODS(Output Delivery System)

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

  18. ODS RTF Output(rich text file) ods rtf file='C:\old_computer\teaching\EPIB698A\freq.rtf'; proc freq data=blood; Table GENDER; RUN; ods rtf close; Rft file

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

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

More Related