The data is defined directly in the script via the CARDS statement in the DATA step 'a'.
1 Code Block
DATA STEP Data
Explanation : Initialization of global graphics options and creation of the source dataset 'a' containing the variables TEST (category) and BREAKS (value).
Explanation : Sorting data by the group variable 'TEST' to prepare for aggregation.
Copied!
/* Sort data by variable TEST */
proc sort; by TEST; run;
1
/* Sort
2
data by variable TEST */
3
PROC SORT;
4
BY TEST;
5
6
RUN;
7
3 Code Block
PROC MEANS Data
Explanation : Calculation of descriptive statistics (mean, standard deviation, min, max) grouped by 'TEST'. Results are stored in output table 'b'.
Copied!
/**************************************************/
/* Create an output data set, B using PROC MEANS */
/* that contain new variables, MEAN, STD, STDERR, */
/* MIN, and MAX. */
/**************************************************/
proc means mean std stderr min max data=a;
by TEST;
output out=b mean=mean min=min max=max;
run;
Explanation : Creation of a special 'Annotate' dataset. It defines graphical commands (move, draw) to draw blue lines from min to max, and red markers for the mean, min, and max. Uses the data coordinate system (xsys='2', ysys='2').
Copied!
/****************************************************************/
/* Create an annotate data set, ANNO to draw the bars at +/- 1, */
/* 2, or 3 Standard Deviation or Standard Error of the mean. */
/****************************************************************/
data anno;
retain xsys ysys '2' when 'a';
length color function $8 ;
set b;
/* Draw the horizontal line from min to max */
function='move'; xsys='2'; ysys='2'; yc=TEST; x=min; color='blue'; output;
function='draw'; x=max; color='blue'; size=2; output;
/* Draw the MEAN horizontal line making the SIZE bigger */
function='move'; xsys='2';ysys='2';yc=TEST;x=mean; color='red'; output;
function='draw'; x=mean; ysys='9'; y=+2; size=4; output;
function='draw'; x=mean; y=-4; size=4; output;
/* Draw the line for the MIN value */
function='move';xsys='2';ysys='2';yc=TEST;x=min;color='red';output;
function='draw';x=min;ysys='9';y=+2;size=2;output;
function='draw';x=min;y=-4;size=2;output;
/* Draw the line for the MAX value */
function='move';xsys='2';ysys='2';yc=TEST;x=max;color='red';output;
function='draw';x=max;ysys='9';y=+2;size=2;output;
function='draw';x=max;y=-4;size=2;output;
run;
Explanation : Generation of the final graph. The GPLOT procedure uses the 'anno' dataset to superimpose custom drawings on the defined axes. The horizontal axis is set from 0 to 100.
Copied!
axis1 order=(0 to 100 by 10);
symbol1 i=none v=none c=black;
proc gplot data=b ;
plot test*mean / anno=anno haxis=axis1 href=30 60 90; /* The HREF= option draws reference lines */
run;
quit;
1
axis1 order=(0 to 100BY10);
2
symbol1 i=none v=none c=black;
3
4
PROC GPLOTDATA=b ;
5
plot test*mean / anno=anno haxis=axis1 href=306090; /* The HREF= option draws reference lines */
6
RUN;
7
QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.