PROC SGPLOT- continous data

Last changed: 16 August 2019

Many plots can be made with the procedure SGPLOT. We illustrate here some typical cases for continuous  data and on the following page some plots for categorical data.

Import the data set water.xlsx or use this SAS program to read the data. Call the data set water.

Histogram

proc sgplot data=water;
histogram Ntot;
run;

Or one histogram for each month:

proc sgpanel data=water;
panelby month;
histogram Ntot;
run;

 

Boxplot

proc sgplot data=water;
vbox Ntot;
run;

 

Tme series plot

Proc sgplot data = water;
series x = date y = Ntot;
series x = date y = NO3;
run;

 

The properties of the graph can be controlled using a lot or different features. Here are some examples:

proc sgplot data = water;
series x= date y = Ntot / legendlabel = 'Total Nitrogen'
markers lineattrs =(thickness=2);
series x= date y = NO3 / legendlabel = 'Nitrate'
markers lineattrs = (thickness=2);
Title 'Total Nitrogen and Nitrate';
run;

write and run

title;

after this graph to remove the title, which will otherwise will be in all your plots and outputs.

 

Scatter plots

Scatter plots are used to see if there is  a relationship between two variables.

proc sgplot data=water;
scatter x=discharge y=ntot;
run;

and with groupings per month:

proc sgplot data=water;
scatter x=discharge y=ntot /group=month;
run;

or a scatter matrix for several variables:

proc sgscatter data=yourdata;
matrix Ntot NO3 discharge Watertemp ;
run;

or a scatter matrix including histograms in the diagonal:

proc sgscatter data=water;
matrix Ntot NO3 discharge Watertemp /diagonal=(histogram normal);
run;


Contact