Show Menu
Cheatography

SAS sgplot Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

General Syntax

proc sgplot data=sashelp.class;
    scatter x=height y=weight;
    ellipse x=height y=weight / type=predicted
run;

proc sgpanel data=sashelp.heart noautolegend;
  title "Cholesterol Distribution";
  panelby sex;
  histogram cholesterol;
  density cholesterol;
run;

Basic Types

Basic
scatter, series, step, band, needle, vector
Fit and confidence
loess, regres­sion, penalized B-Spline curves, ellipses
Distri­bution
box plots, histog­rams, normal and kernel density estimates
Catego­riz­ation
dot plots, bar charts, line plots
Basic and Fit and confidence plots may be used together, otherwise different categories must not be mixed. Box plots cannot be combined.

Plot Axes

Axis Statements
XAXIS, X2AXIS, YAXIS, Y2AXIS
Axis Types
Discrete, Linear, Logari­thmic, Time

General Options

LEGENDLABEL=, NAME=, TRANSPARENCY=

Marker Symbols

Set via MARKER­ATTRS= option

Line Patterns

Set via LINEATTRS= option

PROC sgplot DATA=

[NO]CYCLEATTRS, DESCRIPTION=, NOAUTOLEGEND, TMPLOUT=, UNIFORM=[GROUP | SCALE | ALL]

SCATTER X= Y=

DATALABEL=, ERRORBARATTRS=, FREQ=, MARKERATTRS=, MARKERCHAR=, MARKERCHARATTRS=, NOMISSINGGROUP, , XERRORLOWER=, XERRORUPPER=, YERRORLOWER=, YERRORUPPER=, GROUP=
Creates a scatter plot.

SERIES X= Y=

BREAK, CURVELABEL[=], CURVELABELPOS=[MIN | MAX | START | END], DATALABEL[=], LINEATTRS=, MARKERATTRS=, MARKERS, NOMISSINGGROUP, GROUP=
Creates a series plot.

STEP X= Y=

BREAK, CURVELABEL[=], CURVELABELPOS= [MIN | MAX | START | END], DATALABEL[=], ERRORBARATTRS=, JUSTIFY= [LEFT | CENTER | RIGHT], LINEATTRS=, MARKERATTRS=, MARKERS, NOMISSINGGROUP, YERRORLOWER=, YERRORUPPER=, GROUP=
Creates a step plot.

BAND [X|Y]= UPPER= LOWER=

FILL | NOFILL, FILLATTRS=, LINEATTRS=, MODELNAME=, NOEXTEND, NOMISSINGGROUP, OUTLINE | NOOUTLINE, GROUP=
Creates a band that highlights part of the plot.

NEEDLE Statement

BASELINE=, DATALABEL[=], LINEATTRS=, MARKERATTRS=, MARKERS, NOMISSINGGROUP, URL=, GROUP=
Creates a plot with needles connecting each point to the baseline.

VECTOR X= Y=

ARROWDIRECTION= [OUT | IN | BOTH], ARROWHEADSHAPE=, DATALABEL[=], LINEATTRS=, NOARROWHEADS, NOMISSINGGROUP, XORIGIN=, YORIGIN=, GROUP=
Creates a vector plot that draws arrows from a point of origin to each data point.

LOESS X= Y=

ALPHA=, CLM[=], CLMATTRS=, CLMTRANSPARENCY=, CURVELABEL[=], CURVELABELLOC= [OUTSIDE | INSIDE], CURVELABELPOS= [MIN | MAX | START | END], DATALABEL[=], DEGREE= [1 | 2], INTERPOLATION= [CUBIC | LINEAR], LINEATTRS=, MARKERATTRS=, MAXPOINTS=, NOLEGCLM, NOLEGFIT, NOMARKERS, REWEIGHT=, SMOOTH=, WEIGHT=, GROUP=
Creates a fitted loess curve.

REG X= Y=

ALPHA=, CLI[=], CLIATTRS=, CLM[=], CLMATTRS=, CLMTRANSPARENCY=, CURVELABEL[=], CURVELABELLOC=[OUTSIDE | INSIDE], CURVELABELPOS=[MIN | MAX | START | END], DATALABEL[=], DEGREE=, FREQ=, LINEATTRS=, MARKERATTRS=, MAXPOINTS=, NOLEGCLI, NOLEGCLM, NOLEGFIT, NOMARKERS, WEIGHT=, GROUP=
Creates a fitted regression line or curve.

PBSPLINE X= Y=

ALPHA=, CLI[=], CLIATTRS=, CLM[=], CLMATTRS=, CLMTRANSPARENCY=, CURVELABEL[=], CURVELABELLOC=[OUTSIDE | INSIDE], CURVELABELPOS=[MIN | MAX | START | END], DATALABEL[=], DEGREE=, FREQ=, LINEATTRS=, MARKERATTRS=, MAXPOINTS=, NKNOTS=, NOLEGCLI, NOLEGCLM, NOLEGFIT, NOMARKERS, SMOOTH=, WEIGHT=, GROUP=
Creates a fitted penalized B-spline curve.

ELLIPSE X= Y=

ALPHA=, CLIP, FILL | NOFILL, FILLATTRS=, FREQ=, LINEATTRS=, OUTLINE | NOOUTLINE, TYPE = MEAN | PREDICTED
Adds a confidence or prediction ellipse to another plot.

[H|V]BOX response variable

BOXWIDTH=, CATEGORY=, DATALABEL[=], EXTREME, FREQ=, LABELFAR, MISSING, PERCENTILE=, SPREAD
Creates a horizontal / vertical box plot that shows the distri­bution of your data.

DENSITY response variable

FREQ=, LINEATTRS=, SCALE=, TYPE= [NORMAL | KERNEL]
Creates a density curve that shows the distri­bution of values in your data.

HISTOGRAM response variable

BOUNDARY= LOWER | UPPER, FILL | NOFILL, FILLATTRS=, FREQ=, OUTLINE | NOOUTLINE, SCALE= [COUNT | PERCENT | PROPORTION], SHOWBINS
Creates a histogram that displays the frequency distri­bution of a numeric value.

DOT category variable

ALPHA=, DATALABEL[=], FREQ=, LIMITATTRS=, LIMITS= [BOTH | LOWER | UPPER], LIMITSTAT= [CLM | STDDEV | STDERR], MARKERATTRS=, MISSING, NOSTATLABEL, NUMSTD=, RESPONSE=, STAT= [FREQ | MEAN | SUM], WEIGHT=
Creates a dot plot that summarizes the values of a category variable.

[H|V]BAR category variable

ALPHA=, BARWIDTH=, DATALABEL, FILL | NOFILL, FILLATTRS=, FREQ=, LIMITATTRS=, LIMITS= [BOTH | LOWER | UPPER], LIMITSTAT= CLM | STDDEV | STDERR, MISSING, NOSTATLABEL, NUMSTD=, OUTLINE | NOOUTLINE, RESPONSE=, STAT= [FREQ | MEAN | SUM], WEIGHT, GROUP=
Creates a bar chart that summarizes the values of a category variable.

[H|V]LINE category variable

ALPHA=, BREAK, CURVELABEL, CURVELABELPOS= [MIN | MAX |START | END], DATALABEL[=], FREQ=, LIMITATTRS=, LIMITS= [BOTH | LOWER | UPPER], LIMITSTAT= [CLM | STDDEV | STDERR], LINEATTRS=, MARKERATTRS=, MARKERS, MISSING, NOSTATLABEL, NUMSTD=, RESPONSE=, STAT= [FREQ | MEAN | SUM], URL=, WEIGHT=, GROUP=
Creates a horizontal / vertical line plot (the line is vertical / horizo­ntal). You can use the [H|V]LINE statement with the [H|V]BAR statement to create a bar-line chart.
 

PANELBY variab­le(s)

BORDER | NOBORDER, COLHEADERPOS=[TOP | BOTTOM | BOTH], COLUMNS=, LAYOUT= [LATTICE | PANEL | ROWLATTICE | COLUMNLATTICE], MISSING, NOVARNAME, ONEPANEL, ROWHEADERPOS=[RIGHT | LEFT | BOTH], ROWS=, SPACING=, SPARSE, START= TOPLEFT | BOTTOMLEFT, UNISCALE= ROW | ALL
May only be used with proc sgpanel.