SAS: Proc GPLOT
Computing for Research I 01/26/2011
- N. Baker
SAS: Proc GPLOT Computing for Research I 01/26/2011 N. Baker - - PowerPoint PPT Presentation
SAS: Proc GPLOT Computing for Research I 01/26/2011 N. Baker Introduction to SAS/GRAPH Graphics component of SAS system. Includes charts, plots, and maps in both 2 and 3 dimensions. Procedures included GCHART, GPLOT, GMAP,
These samples courtesy of Robert Allison’s SAS Graph Examples
Taken from SAS 9.2 documentation
ODS Destination Elements Global Statements Procedure Step
Options include setting annotate data sets, image mapping for drill-down plots in web applications, Creating Uniform axis across plots, and specifying SAS catalog for placement of output.
plot
colors used for axis, frame, text or reference lines.
y1 1 2 3 x 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
Very basic plot, below we get all of the default options. Not very exciting. Definitely not publication quality. Cannot read axis marks Axis labels don’t describe the data Crowded Axis
– Options precede label
– Example order=(0 to 3 by 1);
– Example Value=( “Start” “Middle” “End”)
Resets previous
Horizontal axis (X Variable) Vertical axis (Y Variable) Call Axis statements NOTE: you can also place the AXIS statements within the gplot proc
Plasma Level
1 2 3
D o se
m g /24 H rs
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
The LABEL options helped make the axis labels meaningful, but the axis tick marks remain crowded
Added ORDER
statement
Plasma Level
1 2 3
D ose
m g/24 Hrs
0.0 0.5 1.0 1.5 2.0
The axis are less crowded, but still very hard to read, using the Value= option will help.
Added VALUE
statement
Plasma Level
0.0 1.0 2.0 3.0
D o se
m g/24 H rs 0.0 0.5 1.0 1.5 2.0
Now about those data points!
– Join, box, hilo interpolation, regression, spline, standard deviations.
– Dot, circle, star, square, plus, minus, “text value”.
– 256 colors available,
www.devenezia.com/docs/SAS/sas-colors.html
– None – Join: points connected by straight line – Needle: vertical line from horizontal axis to point – Stepx: (L,R,C) step function, stepxJ will add a verticle line to each step plot – stdkxxx: (M,P,J,B,T) k=1,2,3 (standard deviations) or » stdM=SEM, stdp=uses pooled sample variance, stdj=joins the errors, T will give tops and bottoms to error lines, where B will request error bars. – HILOxxx: (T,B,C,J)
– R-series interpolation – Rxxxxxxx » RL: linear regression » RQ: Quadratic Regression » RC: Cubic Regression » CLM: CI for mean predicted values » CLI: CI for Individual predicted values » 90, 95, 99: confidence limits
Plasma Level
0.0 1.0 2.0 3.0
D o s e
m g /2 4 H r s 0 .0 0 .5 1 .0 1 .5 2 .0
Plasma Level
0.0 1.0 2.0 3.0
D o s e
m g /2 4 H r s 0 .0 0 .5 1 .0 1 .5 2 .0
R e g re s s io n E q u a t io n : y 1 = 0 . 4 8 1 1 7 3 + 1 . 2 6 9 4 3 3 * x
You need to add a new SYMBOL statement for the each additional group. Add the grouping variable to the PLOT statement
Plasma Level
0.0 1.0 2.0 3.0
Dose
m g/24 Hrs 0.0 0.5 1.0 1.5 2.0
gender
Fem ale M ale
Not bad, but the figure legend is not well placed.
These options are the same as within the axis statement discussed earlier
Legend Statement Call Legend Statement
Plasma Level
0.0 1.0 2.0 3.0
D o se
m g/24 H rs 0.0 0.5 1.0 1.5 2.0
G ender Fem ale M ale
– During the last week, both treatment groups receive Placebo
AXIS for X (time) variable AXIS for Y (Response) variable Added TITLE statement for plot
Response
1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 1 0 0
T im e S in c e D ia g n o s is : W e e k s
B a s e lin e 1 2 3 4
In d i v i d u a l D i s e a s e P r o g r e s s i o n
Joins the dots, By ID
Response
1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 1 0 0
T im e S in c e D ia g n o s is : W e e k s
B a s e lin e 1 2 3 4
In d i v i d u a l D i s e a s e P r o g r e s s i o n
Response
1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 1 0 0
T im e S in c e D ia g n o s is : W e e k s
B a s e lin e 1 2 3 4
In d i v i d u a l D i s e a s e P r o g r e s s i o n
T re a tm e n t G ro u p Tr e a tm a n t A P la c e b o
Plot data by trt group and create a symbol statement for each group
50 subjects randomized to either low or high dose medication. Tumor size is measured at baseline as well as the following 9 weeks. The investigator would like an easy to present plot containing both pieces of information for a presentation to his peers.
Tumor Growth
10 20 30 40 50 60 70 80
Time Since Diagnosis: W eeks
Baseline 1 2 3 4 5 6 7 8 9
Individual Disease Progression
Tumor Growth
10 20 30 40 50 60 70 80
Tim e Since Diagnosis: W eeks
Baseline 1 2 3 4 5 6 7 8 9
Individual Disease Progression
T reatment G roup Low Dose High Dose
Plot of individual values as before Plot of treatment group means and Standard errors as before Grouping variable Symbol repeats
Tumor Growth
10 20 30 40 50 60 70 80
Time Since Randomization: W eeks
Baseline 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80
Individual Disease Progression
Treatment Group
Low Dose High Dose
Use proc logistic to output the predicted probability of developing nephropathy given the baseline Oxidized LDL immune complex level as well as the 95% confidence limits. Many PROCs can output predicted values, adjusted means, along with point wise confidence values.
0.0 0.2 0.4 0.6 0.8
Baseline Ox LDL-IC
1.80 2.14 2.48 2.82 3.16 3.50 3.84 4.18 4.52 4.86 5.20 5.54 5.88 6.22 6.56 6.90
Baseline LDL & HDL (mg/dl)
50 100 150 200 250
Baseline OxLDL-IC Quartile
1st 2nd 3rd 4th
Baseline OxLDL-IC
100 200 300 400 500
Baseline Characteristics
OxLDL-IC LDL Cholesterol HDL Cholesterol
Baseline Characteristics
OxLDL-IC
this data file will give commands to SAS/GRAPH Specific variables must be in the annotate data set. Others are allowed but ignored What, how, and where are defined by these variables. Table 1 list important variables.
Taken from Mink and Pasta, SUGI 31
HbA1c
6.0 % 6.5 % 7.0 % 7.5 % 8.0 % 8.5 % 9.0 % 9.5 % 10.0 %
S tu d y T im e
Y e ars
B L 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9
M ean HbA 1c % durring D C C T /E D IC study
Proc GPLOT global options help make graphs more pleasing, however, there are cases where more work is needed to fully explain the data
Created shaded regions to designate study sections Deleted regions of non interest Added treatment group and study section labels
$ 0.00 $ 0.10 $ 0.20 $ 0.30 $ 0.40 $ 0.50 $ 0.60 $ 0.70 $ 0.80 $ 0.90 $ 1.00
Year
Individual Net Worth
As a Function of Original Worth
Suppose you want To jazz up your plots for a
Or graphic behind you data to accent The results. We are going to place an image behind the data, but only below The data series. NEAT!
Anno data set 1: Will place the image
the plotting area. Anno data set 2: Will create white Space above the Plotted line over time. SET the anno data sets and call them in the GPLOT statement
$ 0.00 $ 0.10 $ 0.20 $ 0.30 $ 0.40 $ 0.50 $ 0.60 $ 0.70 $ 0.80 $ 0.90 $ 1.00
Year
Individual Net Worth
As a Function of Original Worth