• Save
Sas Plots Graphs
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Sas Plots Graphs

on

  • 5,845 views

Learning ...

Learning
Base SAS,
Advanced SAS,
Proc SQl,
ODS,
SAS in financial industry,
Clinical trials,
SAS Macros,
SAS BI,
SAS on Unix,
SAS on Mainframe,
SAS interview Questions and Answers,
SAS Tips and Techniques,
SAS Resources,
SAS Certification questions...

visit http://sastechies.blogspot.com

Statistics

Views

Total Views
5,845
Views on SlideShare
5,830
Embed Views
15

Actions

Likes
7
Downloads
0
Comments
0

1 Embed 15

http://www.slideshare.net 15

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005
  • SASTechies.com Sharad C Narnindi Attic Technologies,Inc 2005

Sas Plots Graphs Presentation Transcript

  • 1. SASTechies [email_address] http://www.sastechies.com
  • 2.
    • Creating
      • SAS Tables,
      • Listings,
      • Basic Statistics Procedures with SAS
      • Graphs
      • ODS HTML
      • Proc Report and Other Utility Procedures
    11/13/09 SAS Techies 2009 TLG’s
  • 3.
    • proc format;
    • value $repfmt 'TFB'='Bynum' 'MDC'='Crowley' 'WKK'='King';
    • value cntyfmt 12='Durham' 45='Wake' 13='Orange';
    • run;
    • proc print data=vcrsales;
    • var salesrep county unitsold;
    • format salesrep $ repfmt . County cntyfmt . ; run;
    11/13/09 SAS Techies 2009
  • 4.
    • title1 'Heart Rates for Patients with';
    • title3 'Increased Stress Tolerance Levels';
    • In SAS listing output , title line 2 appears blank
    • In HTML output , title lines simply appear consecutively, without extra spacing to indicate skipped title numbers.
    • TITLE < n> ' title-text ';    
    • where n is a number from 1 to 10 that specifies the title line, and 'title-text' is the actual title to be displayed.
    • The maximum title length depends on your operating environment and the value of the linesize=option
    • Title statement is global and additive
    • Cancelling titles
    • A TITLE statement remains in effect until you modify it, cancel it, or end your SAS session.
    • Redefining a title line cancels any higher-numbered title lines.
    • To cancel all previous titles, specify a null TITLE statement
    11/13/09 SAS Techies 2009 Heart Rates for Patients with Increased Stress Tolerance Levels Obs RestHR MaxHR RecHR 2 68 171 133 3 78 177 139 8 70 167 122 11 65 181 141 14 74 152 113 15 75 158 108 20 78 189 138
  • 5.
    • FOOTNOTE < n> ' footnote-text ';     where n is a number from 1 to 10 that specifies the footnote line, and footnote-text is the actual footnote to be displayed.
    • The maximum footnote length depends on your operating environment and the value of the LINESIZE= option.
    • Be sure to match quotation marks that enclose the footnote text.
    • Footnote statement is global and additive
    11/13/09 SAS Techies 2009 Obs RestHR MaxHR RecHR 2 68 171 133 3 78 177 139 8 70 167 122 11 65 181 141 14 74 152 113 15 75 158 108 20 78 189 138 Data from Treadmill Tests 1st Quarter Admissions
  • 6.
    • how to create single plots and overlaid plots, then refine the plots by scaling axes, defining plotting symbols, and specifying methods of interpolating plotted points.
    • GPLOT procedure
    • PROC GPLOT DATA= SAS-data-set ;         PLOT vertical-variable*horizontal-variable ; RUN;
    11/13/09 SAS Techies 2009
  • 7.
    • proc gplot data=clinic.totals2000; plot newadmit*month; run;
    • PLOT vertical-variable*horizontal-variable /             VAXIS= <value-list | range>             HAXIS= <value-list | range > ;
    • Ex. vaxis=10 to 100 by 10
    11/13/09 SAS Techies 2009
  • 8.
    • PLOT vertical-variable-1*horizontal-variable             vertical-variable-2*horizontal-variable /   OVERLAY;
    • If the OVERLAY option were not specified, each plot request would generate a separate graph
    • SYMBOL statement is used to enhance your plots by specifying plotting symbols, plot lines, color, and interpolation.
    • Interpolation is a technique for estimating values between plot points and drawing lines to connect the points.
    11/13/09 SAS Techies 2009 proc gplot data=clinic.totals2000; plot therapy*month treadmill*month / overlay ; run; |<--pair1-->| |<---pair2--->|
  • 9.
    • symbol1 color=red value=star interpol=spline height=1 cm width=4; proc gplot data=clinic.totals2000;
    • plot therapy*month; run;
    11/13/09 SAS Techies 2009 symbol1 color=red value=star interpol=spline height=1 cm width=4; symbol2 color=green value=plus interpol=spline height=1 cm width=4;   VALUE=   plotting symbol   HEIGHT=   height of the plotting symbol   INTERPOL=     interpolation technique   WIDTH=   thickness of the line in pixels   COLOR=   color of plotting symbols or lines 
  • 10.
    • Setting Plotting Symbols The VALUE= (or V= ) option specifies the plotting symbol that represents each data point. Possible values for the VALUE= option include
    • the letters A through W
    • the numbers 0 through 9
    • a number of special symbols including PLUS , STAR , SQUARE , DIAMOND , TRIANGLE , and many others
    • NONE , which produces a plot with no symbols for data points.
    11/13/09 SAS Techies 2009
  • 11.
    • Setting Plotting Symbol Height You can use the HEIGHT= (or H= ) option to specify the height of the plotting symbol. You can specify a value for height and a unit of measurement. Valid units are
    • percentage of the display area ( PCT )
    • inches ( IN )
    • centimeters ( CM )
    • points ( PT )
    • character cells ( CELL ), which is the default unit.
    11/13/09 SAS Techies 2009 symbol1 value=triangle height=1 cm color=black;
  • 12.
    • symbol1 value=triangle interpol=none ;
    • Specifying Connecting Lines To specify whether or not to connect plotted points, you use the INTERPOL= (or I= ) option in the SYMBOL statement. Connecting lines can be straight lines, smoothed lines, or vertical lines drawn from plotted points to a horizontal line at zero or the minimum value on the Y axis.
    • Possible values include NONE , JOIN , NEEDLE , SPLINE , HILO , STD , and more.
    11/13/09 SAS Techies 2009
  • 13.
    •   SYMBOL statements are both global and additive . This means that
    • once defined, they remain in effect until you change/cancel/or end the SAS session
    • within one SYMBOL statement, you can change the value of one option value without affecting the values of other options.
    • Ex: symbol1 value=square color=blue interpol=needle;
    • symbol1 v=triangle;
    11/13/09 SAS Techies 2009
  • 14.
    • Canceling SYMBOL Statement Options
    • an individual option
    • symbol1 interpol=join color=yellow width=1.5;
    • symbol1 color=;
    • all options in one SYMBOL statement
    • symbol1 interpol=join color=yellow width=2 value=square;
    • symbol2 interpol=join color=blue width=2 value=star;
    • symbol2; - Submitting the null SYMBOL2 statement cancels the SYMBOL2 statement but does not affect higher or lower numbered SYMBOL statements.
    • all SYMBOL statements currently in effect.
    • cancel all SYMBOL statements in effect by submitting statement:
    • goptions reset=symbol;
    • When you cancel a SYMBOL statement option, you return the option to its default value.
    11/13/09 SAS Techies 2009
  • 15.
    • symbol1 value=triangle interpol=none color=red; proc gplot data=clinic.totals2000;
    • plot newadmit*month;
    • run;
    • quit;
    • To end the procedure, you must submit another PROC step, a DATA step, or a QUIT statement (shown below). quit;
    • Not all procedures support RUN-group processing, and implementation varies.
    11/13/09 SAS Techies 2009
  • 16. 11/13/09 SAS Techies 2009 symbol1 interpol=spline value=none color=red; symbol2 interpol=spline value=none color=blue; proc gplot data=clinic.therapy1999; plot swim*month aerclass*month/overlay; where swim>35 and aerclass>35; run;
  • 17.
    • proc gplot data=air.airqual;
    • plot avgtsp*month =state /
    • vminor=3 hminor=0
    • areas=2 nolegend;
    • pattern1 color=red;
    • pattern2 color=blue;
    • note move=(10, 19)
    • color=red 'Alabama';
    • note move=(10, 20) color= blue 'California';
    • symbol1 c=red i=spline v=none;
    • symbol2 c=blue i=spline v=none;
    • where state in (&quot;CA&quot; , &quot;AL&quot;);
    • quit;
    11/13/09 SAS Techies 2009
  • 18.
    • PROC GCHART < DATA= SAS-data-set > ;         chart-form chart-variable </ options > ; RUN;
    • SAS-data-set is the name of the SAS data set to be used.
    • chart-form is HBAR, HBAR3D, VBAR, VBAR3D, PIE, or PIE3D. The chart-form specifies a 2D or 3D horizontal bar chart, vertical bar chart, or pie chart, respectively.
    • chart-variable is the variable that determines the number of bars or pie slices.
    • The default statistic for GCHART is FREQ (frequency).
    11/13/09 SAS Techies 2009
  • 19.
    • proc gchart data=clinic.insure;
    • hbar company;
    • run;
    • PROC GCHART < DATA= SAS-data-set > ;         chart-form chart-variable / TYPE= statistic ; RUN; QUIT;
    • Statistics include
    • CFREQ (cumulative frequency), PERCENT (percent), and CPERCENT (cumulative percent).
    • For horizontal bar charts , unless otherwise specified, PROC GCHART also displays the statistics CFREQ PERCENT , and CPERCENT
    • CFREQ  and CPERCENT  are NOT available for pie charts .
    11/13/09 SAS Techies 2009
  • 20.
    • proc gchart data=clinic.insure; vbar company / sumvar=balancedue ; run;
    • SUMVAR= option to summarize a variable within categories.
    • When you specify SUMVAR=, the default statistic is SUM , so the chart displays the total of the values of the summary variable for each unique value of the chart variable.
    • When you use SUMVAR=, you can also use TYPE=. However, the value of TYPE= can be only SUM or MEAN .
    11/13/09 SAS Techies 2009 proc gchart data=clinic.insure; vbar company / sumvar=balancedue type=mean ;
  • 21.
    • proc gchart data=clinic.insure;
    • vbar company / sumvar=balancedue type=mean patternid=midpoint ; run;
    • enhance your charts by specifying patterns other than the default values for bars or slices.
    • PATTERNID= <BY | MIDPOINT | GROUP | SUBGROUP> where BY , MIDPOINT , GROUP , or SUBGROUP specify that bar colors and/or patterns vary according to the option specified.
    • You cannot use the PATTERNID=MIDPOINT option when you create pie charts.
    11/13/09 SAS Techies 2009
  • 22.
    • proc gchart data=clinic.admit; hbar sex / sumvar=weight type=mean group=actlevel patternid=group ; run;
    • pattern1 color=lib ; pattern2 color=lig ; proc gchart data=clinic.admit; hbar age / sumvar=weight type=mean
    • subgroup=sex
    • patternid=subgroup mean; run;
    11/13/09 SAS Techies 2009
  • 23.
    • pie company / sumvar=balancedue type=mean fill=x ;
    • FILL= <X|S> where
    • X changes the fill pattern for all slices to hatch
    • S changes the fill pattern for all slices to solid.
    • You cannot use the FILL= option with bar charts.
    11/13/09 SAS Techies 2009
  • 24.
    • proc gchart data=clinic.insure; pie3d company / sumvar=balancedue type=mean ctext=blue explode= &quot;ACME&quot;; where Company in (&quot;ACME&quot;, &quot;RURITAN&quot;, &quot;USA INC.&quot;); run;
    • pattern1 color=lib;
    • pattern2 color=lig;
    • proc gchart data=clinic.admit;
    • hbar3d age / sumvar=weight type=mean subgroup=sex patternid=subgroup mean; run;
    11/13/09 SAS Techies 2009
  • 25.
    • To save graphs in a SAS catalog other than the default catalog, you use the GOUT= option in the PROC statement for the step that creates your graph. So, when you create charts, you specify GOUT= in the PROC GCHART statement.
    • Ex:
    • symbol1 interpol=spline value=none color=red;
    • symbol2 interpol=spline value=none color=blue;
    • proc gchart data=clinic.therapy1999 gout=newcat ;
    • vbar month / sumvar=swim type=sum;
    • hbar month / sumvar=aerclass type=sum;
    • where swim>35 and aerclass>35;
    • run;
    11/13/09 SAS Techies 2009