/**********************************************************************/
/**********************************************************************/
/*  THE FILES CONTAINED HEREIN ARE PROVIDED BY SAS INSTITUTE INC.     */
/*  "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,  */
/*  INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF            */
/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. RECIPIENTS  */
/*  ACKNOWLEDGE AND AGREE THAT SAS INSTITUTE SHALL NOT BE LIABLE      */
/*  WHATSOEVER FOR ANY DAMAGES ARISING OUT OF THEIR USE OF THIS       */
/*  MATERIAL. IN ADDITION, SAS INSTITUTE WILL PROVIDE NO SUPPORT FOR  */
/*  THE MATERIALS CONTAINED HEREIN.                                   */
/**********************************************************************/
/**********************************************************************/


/**********************************************************************/
/* Authors and Browning-Ferris Industries, Inc. are not responsible   */
/* for any use and/or interpretation made as a result of              */
/* using this code.                                                   */
/**********************************************************************/


libname gdevice0 'c:\sas\611p\sasuser';
filename filein 'c:\sas\trlinear\piper.dat';
filename out 'c:\sas\trlinear\piper.eps';

title;

  GOPTIONS reset=all device=myepsc rotate=landscape nodisplay;
/*GOPTIONS device=win TARGET=WINPRTC; */

OPTIONS MACROGEN SYMBOLGEN MPRINT;

DATA ONE;
INFILE FILEIN;
INPUT LOCNO $1 - 10 LOC $11 - 38 DATE:mmddyy8. CONST $47 - 50
DISTOT $51 CONC 52-64 SITENAME $65-76;
CALL SYMPUT('SITE',TRIM(LEFT(SITENAME)));
RUN;
DATA ONE; SET ONE; IF CONST='FE  ' THEN DELETE; RUN;
DATA ONE; SET ONE(DROP=SITENAME); RUN;
DATA TORD; SET ONE;
IF DISTOT='T' OR DISTOT='D' THEN OUTPUT;
RUN;
DATA TORD; SET TORD;
LENGTH DORT $1.;
DORT=DISTOT;
RUN;

DATA TORD; SET TORD(DROP=LOCNO DATE CONST DISTOT CONC);
RUN;

PROC SORT DATA=TORD OUT=SORTORD;
BY LOC;
RUN;

DATA SORTORD; SET SORTORD; BY LOC;
IF LAST.LOC THEN OUTPUT;
RUN;

PROC SQL;
CREATE TABLE TD AS
SELECT * FROM
ONE LEFT JOIN SORTORD ON ONE.LOC=SORTORD.LOC;
QUIT;

DATA LOOK; SET TD;
LENGTH MISSING $5;
IF CONC=. THEN MISSING='*';
IF CONC=. THEN CONC=0;
RUN;

PROC SORT DATA=TD OUT=SORTONE;
BY LOC DATE CONST;
RUN;
PROC TRANSPOSE DATA=SORTONE OUT=TRANSONE;
BY LOC DATE DORT LOCNO;
VAR CONC;
ID CONST;
RUN;

PROC SORT DATA=TRANSONE OUT=OUT1;
BY LOC DATE;
RUN;
DATA OUT1; SET OUT1; BY LOC;
RETAIN GROUP 100;
IF FIRST.LOC THEN GROUP+1;
RUN;

DATA TRI;
FORMAT LOCNO LOC DATE MG CA NA K CARB BICA SULF CHLO PH DORT SD;
SET OUT1(DROP=_NAME_);
RUN;

PROC SORT DATA=TRI OUT=TRI;
BY GROUP;
RUN;

DATA SORTRAN2; SET TRI;
IF MG=. THEN MG=0;
IF CA=. THEN CA=0;
IF NA=. THEN NA=0;
IF K=. THEN K=0;
IF CARB=. THEN CARB=0;
IF BICA=. THEN BICA=0;
IF SULF=. THEN SULF=0;
IF CHLO=. THEN CHLO=0;
IF PH=. THEN PH=.;
IF SD=. THEN SD=0;
RUN;

DATA RESULT1; SET SORTRAN2;
LINE=1;
MGRES      = MG / 12.156;
CARES      = CA / 20.04;
NARES      = NA / 22.9898;
KRES       = K / 39.102;
LTOTAL = (MGRES + CARES + NARES + KRES);
CARBRES    = CARB / 30.005;
BICARES    = BICA / 61.017;
SULFRES    = SULF / 48.031;
CHLORES    = CHLO / 35.453;
RTOTAL = (CARBRES + BICARES + SULFRES + CHLORES);

IONBAL = 100 * (LTOTAL - RTOTAL) / (LTOTAL + RTOTAL);
ION=PUT(ROUND(IONBAL,0.01),6.2);
RUN;

DATA RESULT3; SET RESULT1;
CATIONS=PUT(ROUND(LTOTAL,0.01),6.2);
ANIONS=PUT(ROUND(RTOTAL,0.01),6.2);
RUN;

PROC SORT DATA=RESULT3 OUT=RESULT3;
BY GROUP;
RUN;

DATA LOOK1; SET RESULT3(KEEP=LOCNO LOC DATE MGRES CARES NARES KRES
CARBRES BICARES SULFRES CHLORES PH ION CATIONS ANIONS GROUP SD);
RUN;
PROC SORT DATA=LOOK1 OUT=SORLOOK1;
BY GROUP;
RUN;
DATA LOOK2; SET SORLOOK1;
RUN;
PROC TRANSPOSE DATA=LOOK2 OUT=TRALOOK2;
BY LOC DATE GROUP ION LOCNO;
RUN;

DATA TRALOOK3; SET TRALOOK2;
LENGTH NEW $4;
IF _NAME_='MGRES' THEN NEW='MG';
IF _NAME_='CARES' THEN NEW='CA';
IF _NAME_='NARES' THEN NEW='NA';
IF _NAME_='KRES' THEN NEW='K';
IF _NAME_='CARBRES' THEN NEW='CARB';
IF _NAME_='BICARES' THEN NEW='BICA';
IF _NAME_='SULFRES' THEN NEW='SULF';
IF _NAME_='CHLORES' THEN NEW='CHLO';
IF _NAME_='PH' THEN NEW='PH';
IF _NAME_='SD' THEN NEW='SD';
RUN;

PROC SQL;
CREATE TABLE WHOLE AS
SELECT * FROM
TRALOOK3 LEFT JOIN LOOK ON TRALOOK3.NEW=LOOK.CONST AND
                           TRALOOK3.LOC=LOOK.LOC AND
                           TRALOOK3.DATE=LOOK.DATE;
QUIT;

DATA WHOLE;
FORMAT LOCNO LOC DATE CONST NEW CONC COL1 MISSING;
SET WHOLE(DROP=_NAME_);
RUN;

PROC SORT DATA=WHOLE OUT=WHOLE;
BY GROUP;
RUN;

DATA RULE; SET WHOLE;
LENGTH RECORD $2;
IF CONST=' ' THEN RECORD='**';
RUN;

DATA RULE; SET RULE;
LENGTH CONST1 $14;
IF NEW='MG' THEN CONST1='MAGNESIUM';
IF NEW='CA' THEN CONST1='CALCIUM';
IF NEW='NA' THEN CONST1='SODIUM';
IF NEW='K' THEN CONST1='POTASSIUM';
IF NEW='CARB' THEN CONST1='CARBONATE';
IF NEW='BICA' THEN CONST1='BICARBONATE';
IF NEW='SULF' THEN CONST1='SULFATE';
IF NEW='CHLO' THEN CONST1='CHLORIDE';
IF NEW='PH' THEN CONST1='PH';
IF NEW='SD' THEN CONST1='TDS';
RUN;
DATA RULE;
FORMAT LOCNO LOC DATE CONST1 NEW DISTOT CONC COL1 MISSING RECORD ION;
SET RULE(DROP=CONST);
RUN;
PROC SORT DATA=RULE OUT=RULE;
BY GROUP CONST1;
RUN;
DATA RULE1;
FORMAT LOCNO LOC DATE CONST1 NEW DISTOT CONC COL1 ION MISSING RECORD;
SET RULE(DROP=GROUP DORT);
RUN;
TITLE ' ';
TITLE3 'BROWNING-FERRIS INDUSTRIES, INC.';
TITLE4 'GROUND WATER SERVICES';
TITLE5 'DATA SERVICES';
TITLE7 "&SITE";
TITLE8 'TRILINEAR DIAGRAM DATA SUMMARY';
TITLE9 ' ';
FOOTNOTE1 '+  UNITS FOR TDS IN MG/L, PH IN SU
                                             ';
FOOTNOTE2 '*  = VALUE MISSING FROM DATABASE (TREATED AS 0)
D = DISSOLVED IONS                           ';
FOOTNOTE3 '** = RECORD MISSING FROM DATABASE (TREATED AS 0)
T = TOTAL IONS                               ';

PROC SORT DATA=RULE1 OUT=RULE2;
BY LOC DATE CONST1;
RUN;

/*OC PRINT DATA=RULE2 NOOBS SPLIT='#';
FORMAT DATE DATE:MMDDYY8.;
FORMAT CONC COL1 10.3;
LABEL LOCNO='LOCATION#ID'
      LOC='LOCATION'
      DATE='DATE'
      CONST1='CONSTITUENT'
      NEW='CODE'
      DISTOT='D/T'
      CONC='CONC#(MG/L)'
      COL1='CONC +#(MEQ/L)  '
      ION='ION#BALANCE#%'
      MISSING='MISSING#VALUE'
      RECORD='MISSING#RECORD';
RUN;  */

TITLE;
FOOTNOTE;
DATA TWO; SET RULE1(DROP=CONST1 COL1 ION MISSING RECORD); RUN;
DATA TORD; SET TWO;
IF DISTOT='T' OR DISTOT='D' THEN OUTPUT;
RUN;
DATA TORD; SET TORD;
LENGTH DORT $1.;
DORT=DISTOT;
RUN;
DATA TORD; SET TORD(DROP=LOCNO DATE NEW DISTOT CONC);
RUN;

PROC SORT DATA=TORD OUT=SORTORD;
BY LOC;
RUN;
DATA SORTORD; SET SORTORD; BY LOC;
IF LAST.LOC THEN OUTPUT;
RUN;

PROC SQL;
CREATE TABLE TD AS
SELECT * FROM
TWO LEFT JOIN SORTORD ON TWO.LOC=SORTORD.LOC;
QUIT;
DATA LOOK; SET TD;
LENGTH MISSING $1;
IF CONC=. THEN MISSING='*';
IF CONC=0 THEN CONC=0;
RUN;
PROC SORT DATA=TD OUT=SORTTWO;
BY LOC DATE NEW;
RUN;
PROC TRANSPOSE DATA=SORTTWO OUT=TRANSTWO;
BY LOC DATE DORT LOCNO;
VAR CONC;
ID NEW;
RUN;
PROC SORT DATA=TRANSTWO OUT=OUT1;
BY LOC DATE;
RUN;
DATA OUT1; SET OUT1; BY LOC;
RETAIN GROUP 100;
IF FIRST.LOC THEN GROUP+1;
RUN;

DATA TRANSONE;
FORMAT LOCNO LOC DATE MG CA NA K CARB BICA SULF CHLO SD PH DORT GROUP;
SET OUT1(DROP=_NAME_);
RUN;
DATA BASIS(RENAME=(MG=MGVAL CA=CAVAL NA=NAVAL K=KVAL
                   CARB=CO3VAL BICA=HCO3VAL SULF=SO4VAL CHLO=CLVAL));
SET TRANSONE(DROP=LOCNO);

DATA RESULT; SET BASIS;
IF MGVAL=. THEN MGVAL=0;
IF CAVAL=. THEN CAVAL=0;
IF NAVAL=. THEN NAVAL=0;
IF KVAL=. THEN KVAL=0;
IF CO3VAL=. THEN CO3VAL=0;
IF HCO3VAL=. THEN HCO3VAL=0;
IF SO4VAL=. THEN SO4VAL=0;
IF CLVAL=. THEN CLVAL=0;
IF SD=. THEN SD=0;
IF PH=. THEN PH=.;
RUN;

DATA MINOR1; SET RESULT; RUN;
PROC SORT DATA=MINOR1 OUT=MINOR1;
BY DORT;
RUN;
DATA MINOR1; SET MINOR1; BY DORT;
IF FIRST.DORT THEN OUTPUT;
RUN;

DATA RESULT; SET RESULT;
IF SD=. OR SD=0 THEN SD=0;
IF 0 < SD <= 500 THEN SD = 1000;
ELSE IF 500 < SD <= 1000 THEN SD = 5000;
ELSE IF 1000 < SD <= 999999 THEN SD = 10000;
RUN;
PROC UNIVARIATE DATA=RESULT NORMAL NOPRINT;
VAR SD;
OUTPUT OUT=SUM1 SUM=SUM;
RUN;
DATA SUM1; SET SUM1;
SD=300000-SUM;
GROUP=100;
MGVAL=.;
CAVAL=.;
NAVAL=.;
KVAL=.;
CO3VAL=.;
HCO3VAL=.;
SO4VAL=.;
CLVAL=.;
PH=.;
DATE=.;
DORT=' ';
LOC=' ';
RUN;
DATA DUMMY; SET SUM1(DROP=SUM); RUN;
PROC APPEND BASE=RESULT DATA=DUMMY; RUN;
PROC SORT DATA=RESULT OUT=RESULT; BY GROUP; RUN;
DATA RESULT; SET RESULT;
MGRES= MGVAL / 12.156;
CARES= CAVAL / 20.04;
NARES= NAVAL / 22.9898;
KRES = KVAL  / 39.102;
LTOTAL =(MGRES + CARES + NARES + KRES);
X1= (100 * CARES / LTOTAL) + ((100 * MGRES / LTOTAL) /(1.8 + .2));
Y1 = (100 * MGRES / LTOTAL);
DATA MAJOR1; SET RESULT; RUN;

DATA RESULT2; SET BASIS;
IF MGVAL=. THEN MGVAL=0;
IF CAVAL=. THEN CAVAL=0;
IF NAVAL=. THEN NAVAL=0;
IF KVAL=. THEN KVAL=0;
IF CO3VAL=. THEN CO3VAL=0;
IF HCO3VAL=. THEN HCO3VAL=0;
IF SO4VAL=. THEN SO4VAL=0;
IF CLVAL=. THEN CLVAL=0;
IF SD=. THEN SD=0;
IF PH=. THEN PH=.;
RUN;

DATA MINOR2; SET RESULT2; RUN;
PROC SORT DATA=MINOR2 OUT=MINOR2;
BY DORT;
RUN;
DATA MINOR2; SET MINOR2; BY DORT;
IF FIRST.DORT THEN OUTPUT;
RUN;

DATA RESULT2; SET RESULT2;
IF SD=. OR SD=0 THEN SD=0;
IF 0 < SD <= 500 THEN SD = 1000;
ELSE IF 500 < SD <= 1000 THEN SD = 5000;
ELSE IF 1000 < SD <= 999999 THEN SD = 10000;
RUN;
PROC UNIVARIATE DATA=RESULT2 NORMAL NOPRINT;
VAR SD;
OUTPUT OUT=SUM1 SUM=SUM;
RUN;
DATA SUM1; SET SUM1;
SD=300000-SUM;
GROUP=100;
MGVAL=.;
CAVAL=.;
NAVAL=.;
KVAL=.;
CO3VAL=.;
HCO3VAL=.;
SO4VAL=.;
CLVAL=.;
PH=.;
DATE=.;
DORT=' ';
LOC=' ';
RUN;
DATA DUMMY; SET SUM1(DROP=SUM); RUN;
PROC APPEND BASE=RESULT2 DATA=DUMMY; RUN;
PROC SORT DATA=RESULT2 OUT=RESULT2; BY GROUP; RUN;
DATA RESULT2; SET RESULT2;
CO3RES= CO3VAL / 30.005;
HCO3RES= HCO3VAL / 61.017;
SO4RES = SO4VAL / 48.031;
CLRES = CLVAL  / 35.453;
RTOTAL = (CO3RES + HCO3RES + SO4RES + CLRES);
X1= (100 * CLRES / RTOTAL) + ((100 * SO4RES / RTOTAL) /(1.8 + .2));
Y1 = (100 * SO4RES / RTOTAL);
DATA MAJOR2; SET RESULT2; RUN;

DATA ANNO1  ;
INPUT  X Y FUNCTION $
SIZE COLOR $8. POSITION $1. XSYS $1. YSYS $1. HSYS $1. ANGLE ROTATE
STYLE $8. TEXT $30.;
DATALINES;
100 0   MOVE  . .       522  . . . .
0   0   DRAW  1 BLUE    522  . . . .
50  100 DRAW  1 BLUE    522  . . . .
100 0   DRAW  1 BLUE    522  . . . .
90  0   MOVE  . .       522  . . . .
45  90  DRAW  1 BLUE    522  . . . .
80  0   MOVE  . .       522  . . . .
40  80  DRAW  1 BLUE    522  . . . .
70  0   MOVE  . .       522  . . . .
35  70  DRAW  1 BLUE    522  . . . .
60  0   MOVE  . .       522  . . . .
30  60  DRAW  1 BLUE    522  . . . .
50  0   MOVE  . .       522  . . . .
25  50  DRAW  1 BLUE    522  . . . .
40  0   MOVE  . .       522  . . . .
20  40  DRAW  1 BLUE    522  . . . .
30  0   MOVE  . .       522  . . . .
15  30  DRAW  1 BLUE    522  . . . .
20  0   MOVE  . .       522  . . . .
10  20  DRAW  1 BLUE    522  . . . .
10  0   MOVE  . .       522  . . . .
5   10  DRAW  1 BLUE    522  . . . .
90  0   MOVE  . .       522  . . . .
95  10  DRAW  1 BLUE    522  . . . .
80  0   MOVE  . .       522  . . . .
90  20  DRAW  1 BLUE    522  . . . .
70  0   MOVE  . .       522  . . . .
85  30  DRAW  1 BLUE    522  . . . .
60  0   MOVE  . .       522  . . . .
80  40  DRAW  1 BLUE    522  . . . .
50  0   MOVE  . .       522  . . . .
75  50  DRAW  1 BLUE    522  . . . .
40  0   MOVE  . .       522  . . . .
70  60  DRAW  1 BLUE    522  . . . .
30  0   MOVE  . .       522  . . . .
65  70  DRAW  1 BLUE    522  . . . .
20  0   MOVE  . .       522  . . . .
60  80  DRAW  1 BLUE    522  . . . .
10  0   MOVE  . .       522  . . . .
55  90  DRAW  1 BLUE    522  . . . .
95  10  MOVE  . .       522  . . . .
5   10  DRAW  1 BLUE    522  . . . .
90  20  MOVE  . .       522  . . . .
10  20  DRAW  1 BLUE    522  . . . .
85  30  MOVE  . .       522  . . . .
15  30  DRAW  1 BLUE    522  . . . .
80  40  MOVE  . .       522  . . . .
20  40  DRAW  1 BLUE    522  . . . .
75  50  MOVE  . .       522  . . . .
25  50  DRAW  1 BLUE    522  . . . .
70  60  MOVE  . .       522  . . . .
30  60  DRAW  1 BLUE    522  . . . .
65  70  MOVE  . .       522  . . . .
35  70  DRAW  1 BLUE    522  . . . .
60  80  MOVE  . .       522  . . . .
40  80  DRAW  1 BLUE    522  . . . .
55  90  MOVE  . .       522  . . . .
45  90  DRAW  1 BLUE    522  . . . .
25.7 22    TEXT  2 GREEN   B32 . . NONE     20
74.3 22    TEXT  2 GREEN   B32 . . NONE     80
31.7 42    TEXT  2 GREEN   B32 . . NONE     40
69.0 42    TEXT  2 GREEN   B32 . . NONE     60
37.3 62    TEXT  2 GREEN   B32 . . NONE     60
63.3 62    TEXT  2 GREEN   B32 . . NONE     40
43.7 82    TEXT  2 GREEN   B32 . . NONE     80
57.3 82    TEXT  2 GREEN   B32 . . NONE     20
30   55    TEXT  2 RED     B32 . . NONE     M
32   62    TEXT  2 RED     B32 . . NONE     G
64   75    TEXT  2 RED     B32 . . NONE     N
66   67    TEXT  2 RED     B32 . . NONE     A
68   59    TEXT  2 RED     B32 . . NONE     +
70   51    TEXT  2 RED     B32 . . NONE     K
51   2     TEXT  2 BLUE    B34 . . NONE    CATIONS
50   5     TEXT  2 RED     B34 . . NONE    CA
33   7     TEXT  2 GREEN   B34 . . NONE     80
44   7     TEXT  2 GREEN   B34 . . NONE     60
55   7     TEXT  2 GREEN   B34 . . NONE     40
67   7     TEXT  2 GREEN   B34 . . NONE     20
;
RUN;
DATA ANNO1A;
LENGTH TEXT $30 FUNCTION $8;
RETAIN FUNCTION 'TEXT'
       SIZE 2
       COLOR 'BLUE' STYLE 'NONE'
       POSITION 'B' XSYS '3' YSYS '4';
SET MINOR1;
BY DORT;
IF FIRST.DORT THEN DO;
   X=38;   Y=0;   TEXT=DORT;
   OUTPUT;
END;
DATA ANNO1A; SET ANNO1A;
LENGTH HSYS $1;
HSYS=' ';
ANGLE=.;
ROTATE=.;
RUN;
DATA ANNO1A; SET ANNO1A(DROP=LOC DATE MGVAL CAVAL NAVAL KVAL
                             CO3VAL HCO3VAL SO4VAL CLVAL
                             SD PH);
RUN;
DATA ANNO1B; SET ANNO1 ANNO1A; RUN;
PROC SORT DATA=ANNO1B OUT=ANNO1B;
BY GROUP;
RUN;

PROC GPLOT DATA=RESULT ANNOTATE=ANNO1B GOUT=GRAPH1;
SYMBOL;
SYMBOL1  H=2 V=NONE   COLOR=GREEN;
SYMBOL2  H=2 V=A      COLOR=GREEN;
SYMBOL3  H=2 V=B      COLOR=GREEN;
SYMBOL4  H=2 V=C      COLOR=GREEN;
SYMBOL5  H=2 V=D      COLOR=GREEN;
SYMBOL6  H=2 V=E      COLOR=GREEN;
SYMBOL7  H=2 V=F      COLOR=GREEN;
SYMBOL8  H=2 V=G      COLOR=GREEN;
SYMBOL9  H=2 V=H      COLOR=GREEN;
SYMBOL10 H=2 V=I      COLOR=GREEN;
SYMBOL11 H=2 V=J      COLOR=GREEN;
SYMBOL12 H=2 V=K      COLOR=GREEN;
SYMBOL13 H=2 V=L      COLOR=GREEN;
SYMBOL14 H=2 V=M      COLOR=GREEN;
SYMBOL15 H=2 V=N      COLOR=GREEN;
SYMBOL16 H=2 V=O      COLOR=GREEN;
SYMBOL17 H=2 V=P      COLOR=GREEN;
SYMBOL18 H=2 V=Q      COLOR=GREEN;
SYMBOL19 H=2 V=R      COLOR=GREEN;
SYMBOL20 H=2 V=S      COLOR=GREEN;
SYMBOL21 H=2 V=T      COLOR=GREEN;
SYMBOL22 H=2 V=U      COLOR=GREEN;
SYMBOL23 H=2 V=V      COLOR=GREEN;
SYMBOL24 H=2 V=W      COLOR=GREEN;
SYMBOL25 H=2 V=X      COLOR=GREEN;
SYMBOL26 H=2 V=Y      COLOR=GREEN;
SYMBOL27 H=2 V=Z      COLOR=GREEN;
AXIS1 LABEL = NONE VALUE = NONE STYLE=0 MAJOR=NONE MINOR=NONE
  ORDER =  0 TO 100 BY 10 OFFSET = (0) LENGTH=4.7 IN ;
AXIS2 ORDER = 100 TO 0 BY -10 OFFSET =(0)   LENGTH=5.6 IN
VALUE= NONE LABEL=NONE
      COLOR=BLUE  MINOR= NONE MAJOR=NONE
                        ;
AXIS3 ORDER = 0 TO 100 BY 10 OFFSET =(0)   LENGTH=5.6 IN
                LABEL =NONE
      COLOR=BLUE  MINOR= NONE MAJOR=NONE
  VALUE =NONE ;
 PLOT  Y1 * X1=GROUP / CTEXT=GREEN HAXIS=AXIS2 VAXIS=AXIS1 NOLEGEND;

DATA ANNO2  ;
INPUT  X Y FUNCTION $
SIZE COLOR $8. POSITION $1. XSYS $1. YSYS $1. HSYS $1. ANGLE ROTATE
STYLE $8. TEXT $30.;
DATALINES;
100 0   MOVE  . .       522  . . . .
0   0   DRAW  1 BLUE    522  . . . .
50  100 DRAW  1 BLUE    522  . . . .
100 0   DRAW  1 BLUE    522  . . . .
90  0   MOVE  . .       522  . . . .
45  90  DRAW  1 BLUE    522  . . . .
80  0   MOVE  . .       522  . . . .
40  80  DRAW  1 BLUE    522  . . . .
70  0   MOVE  . .       522  . . . .
35  70  DRAW  1 BLUE    522  . . . .
60  0   MOVE  . .       522  . . . .
30  60  DRAW  1 BLUE    522  . . . .
50  0   MOVE  . .       522  . . . .
25  50  DRAW  1 BLUE    522  . . . .
40  0   MOVE  . .       522  . . . .
20  40  DRAW  1 BLUE    522  . . . .
30  0   MOVE  . .       522  . . . .
15  30  DRAW  1 BLUE    522  . . . .
20  0   MOVE  . .       522  . . . .
10  20  DRAW  1 BLUE    522  . . . .
10  0   MOVE  . .       522  . . . .
5   10  DRAW  1 BLUE    522  . . . .
90  0   MOVE  . .       522  . . . .
95  10  DRAW  1 BLUE    522  . . . .
80  0   MOVE  . .       522  . . . .
90  20  DRAW  1 BLUE    522  . . . .
70  0   MOVE  . .       522  . . . .
85  30  DRAW  1 BLUE    522  . . . .
60  0   MOVE  . .       522  . . . .
80  40  DRAW  1 BLUE    522  . . . .
50  0   MOVE  . .       522  . . . .
75  50  DRAW  1 BLUE    522  . . . .
40  0   MOVE  . .       522  . . . .
70  60  DRAW  1 BLUE    522  . . . .
30  0   MOVE  . .       522  . . . .
65  70  DRAW  1 BLUE    522  . . . .
20  0   MOVE  . .       522  . . . .
60  80  DRAW  1 BLUE    522  . . . .
10  0   MOVE  . .       522  . . . .
55  90  DRAW  1 BLUE    522  . . . .
95  10  MOVE  . .       522  . . . .
5   10  DRAW  1 BLUE    522  . . . .
90  20  MOVE  . .       522  . . . .
10  20  DRAW  1 BLUE    522  . . . .
85  30  MOVE  . .       522  . . . .
15  30  DRAW  1 BLUE    522  . . . .
80  40  MOVE  . .       522  . . . .
20  40  DRAW  1 BLUE    522  . . . .
75  50  MOVE  . .       522  . . . .
25  50  DRAW  1 BLUE    522  . . . .
70  60  MOVE  . .       522  . . . .
30  60  DRAW  1 BLUE    522  . . . .
65  70  MOVE  . .       522  . . . .
35  70  DRAW  1 BLUE    522  . . . .
60  80  MOVE  . .       522  . . . .
40  80  DRAW  1 BLUE    522  . . . .
55  90  MOVE  . .       522  . . . .
45  90  DRAW  1 BLUE    522  . . . .
25.7 22    TEXT  2 GREEN   B32 . . NONE     80
74.3 22    TEXT  2 GREEN   B32 . . NONE     20
31.7 42    TEXT  2 GREEN   B32 . . NONE     60
69.0 42    TEXT  2 GREEN   B32 . . NONE     40
37.3 62    TEXT  2 GREEN   B32 . . NONE     40
63.3 62    TEXT  2 GREEN   B32 . . NONE     60
43.2 82    TEXT  2 GREEN   B32 . . NONE     20
57.3 82    TEXT  2 GREEN   B32 . . NONE     80
25   35    TEXT  2 RED     B32 . . NONE     C
27.2 43    TEXT  2 RED     B32 . . NONE     O
29.5 51    TEXT  2 RED     B32 . . NONE     3
32   59    TEXT  2 RED     B32 . . NONE     +
34.7 67    TEXT  2 RED     B32 . . NONE     H
36.7 75    TEXT  2 RED     B32 . . NONE     C
38.7 83    TEXT  2 RED     B32 . . NONE     O
40.7 90    TEXT  2 RED     B32 . . NONE     3
66   71    TEXT  2 RED     B32 . . NONE    S
68   63    TEXT  2 RED     B32 . . NONE    O
70   55    TEXT  2 RED     B32 . . NONE    4
51   2     TEXT  2 BLUE    B34 . . NONE    ANIONS
50   5     TEXT  2 RED     B34 . . NONE    CL
33   7     TEXT  2 GREEN   B34 . . NONE     20
44   7     TEXT  2 GREEN   B34 . . NONE     40
55   7     TEXT  2 GREEN   B34 . . NONE     60
67   7     TEXT  2 GREEN   B34 . . NONE     80
;
RUN;
DATA ANNO2A;
LENGTH TEXT $30 FUNCTION $8;
RETAIN FUNCTION 'TEXT'
       SIZE 2
       COLOR 'BLUE' STYLE 'NONE'
       POSITION 'B' XSYS '3' YSYS '4';
SET MINOR2;
BY DORT;
IF FIRST.DORT THEN DO;
   X=40;   Y=0;   TEXT=DORT;
   OUTPUT;
END;
DATA ANNO2A; SET ANNO2A;
LENGTH HSYS $1;
HSYS=' ';
ANGLE=.;
ROTATE=.;
RUN;
DATA ANNO2A; SET ANNO2A(DROP=LOC DATE MGVAL CAVAL NAVAL KVAL
                             CO3VAL HCO3VAL SO4VAL CLVAL
                             SD PH);
RUN;
DATA ANNO2B; SET ANNO2 ANNO2A; RUN;
PROC SORT DATA=ANNO1B OUT=ANNO1B;
BY GROUP;
RUN;
PROC GPLOT DATA=RESULT2 ANNOTATE=ANNO2B GOUT=GRAPH1;
SYMBOL;
SYMBOL1  H=2 V=NONE   COLOR=GREEN;
SYMBOL2  H=2 V=A      COLOR=GREEN;
SYMBOL3  H=2 V=B      COLOR=GREEN;
SYMBOL4  H=2 V=C      COLOR=GREEN;
SYMBOL5  H=2 V=D      COLOR=GREEN;
SYMBOL6  H=2 V=E      COLOR=GREEN;
SYMBOL7  H=2 V=F      COLOR=GREEN;
SYMBOL8  H=2 V=G      COLOR=GREEN;
SYMBOL9  H=2 V=H      COLOR=GREEN;
SYMBOL10 H=2 V=I      COLOR=GREEN;
SYMBOL11 H=2 V=J      COLOR=GREEN;
SYMBOL12 H=2 V=K      COLOR=GREEN;
SYMBOL13 H=2 V=L      COLOR=GREEN;
SYMBOL14 H=2 V=M      COLOR=GREEN;
SYMBOL15 H=2 V=N      COLOR=GREEN;
SYMBOL16 H=2 V=O      COLOR=GREEN;
SYMBOL17 H=2 V=P      COLOR=GREEN;
SYMBOL18 H=2 V=Q      COLOR=GREEN;
SYMBOL19 H=2 V=R      COLOR=GREEN;
SYMBOL20 H=2 V=S      COLOR=GREEN;
SYMBOL21 H=2 V=T      COLOR=GREEN;
SYMBOL22 H=2 V=U      COLOR=GREEN;
SYMBOL23 H=2 V=V      COLOR=GREEN;
SYMBOL24 H=2 V=W      COLOR=GREEN;
SYMBOL25 H=2 V=X      COLOR=GREEN;
SYMBOL26 H=2 V=Y      COLOR=GREEN;
SYMBOL27 H=2 V=Z      COLOR=GREEN;
AXIS1 LABEL = NONE VALUE = NONE STYLE=0 MAJOR=NONE MINOR=NONE
  ORDER =  0 TO 100 BY 10 OFFSET = (0) LENGTH=4.7 IN ;
AXIS2 ORDER = 100 TO 0 BY -10 OFFSET =(0)   LENGTH=5.6 IN
VALUE= NONE LABEL=NONE
      COLOR=BLUE  MINOR= NONE MAJOR=NONE
                        ;
AXIS3 ORDER = 0 TO 100 BY 10 OFFSET =(0)   LENGTH=5.6 IN
                LABEL =NONE
      COLOR=BLUE  MINOR= NONE MAJOR=NONE
  VALUE =NONE ;
 PLOT  Y1 * X1=GROUP /  CTEXT=RED HAXIS=AXIS3   VAXIS=AXIS1
               NOLEGEND;

DATA RESULT; SET BASIS;
IF MGVAL=. THEN MGVAL=0;
IF CAVAL=. THEN CAVAL=0;
IF NAVAL=. THEN NAVAL=0;
IF KVAL=. THEN KVAL=0;
IF CO3VAL=. THEN CO3VAL=0;
IF HCO3VAL=. THEN HCO3VAL=0;
IF SO4VAL=. THEN SO4VAL=0;
IF CLVAL=. THEN CLVAL=0;
IF SD=. THEN SD=0;
IF PH=. THEN PH=.;
RUN;

DATA MINOR3; SET RESULT;
PROC SORT DATA=MINOR3 OUT=MINOR3;
BY DORT;
RUN;
DATA MINOR3; SET MINOR3; BY DORT;
IF FIRST.DORT THEN OUTPUT;
RUN;

DATA RESULT; SET RESULT;
IF SD=. OR SD=0 THEN SD=0;
IF 0 < SD <= 500 THEN SD = 1000;
ELSE IF 500 < SD <= 1000 THEN SD = 5000;
ELSE IF 1000 < SD <= 999999 THEN SD = 10000;
RUN;
PROC UNIVARIATE DATA=RESULT NORMAL NOPRINT;
VAR SD;
OUTPUT OUT=SUM1 SUM=SUM;
RUN;
DATA SUM1; SET SUM1;
SD=300000-SUM;
GROUP=100;
MGVAL=.;
CAVAL=.;
NAVAL=.;
KVAL=.;
CO3VAL=.;
HCO3VAL=.;
SO4VAL=.;
CLVAL=.;
PH=.;
DATE=.;
DORT=' ';
LOC=' ';
RUN;
DATA DUMMY; SET SUM1(DROP=SUM); RUN;
PROC APPEND BASE=RESULT DATA=DUMMY; RUN;
PROC SORT DATA=RESULT OUT=RESULT; BY GROUP; RUN;
DATA RESULT; SET RESULT;
MGRES= MGVAL / 12.156;
CARES= CAVAL / 20.04;
NARES= NAVAL / 22.9898;
KRES = KVAL  / 39.102;
LTOTAL =(MGRES + CARES + NARES + KRES);
CO3RES= CO3VAL / 30.005;
HCO3RES= HCO3VAL / 61.017;
SO4RES = SO4VAL / 48.031;
CLRES = CLVAL  / 35.453;
RTOTAL = (CO3RES + HCO3RES + SO4RES + CLRES);
X1= (-1 * (100 * CARES / LTOTAL))- ((100 * MGRES / LTOTAL)/(1.8 + .2));
Y1 = (100 * MGRES / LTOTAL);
X2= (100 * CLRES / RTOTAL) + ((100 * SO4RES / RTOTAL) /(1.8 + .2));
Y2 = (100 * SO4RES / RTOTAL);
XCONST=(360/(2 * 3.1416));/* CHANGES DEGREES TO RADIANS */
LSUB1= X1;/* ORGINAL LEFT POINT */
A =(Y1/ TAN(60 / XCONST));
APRIME =(Y1 / 2);         /* JUSTINS TEST */
XSUB1=(X1-APRIME )      ;           /* LEFT POINT ON AXIS */
LSUB2=X2;
A = Y2/ TAN(60 / XCONST);
APRIME= Y2 / 2;       /* JUSTINS TEST AGAIN */
XSUB2=X2 + APRIME;        /*  RIGHT POINT ON AXIS */

LSUB3 = ABS(XSUB2)+ ABS(XSUB1);    /* DISTANCE BETWEEN TWO POINTS */

XSUB4 =((XSUB2 + XSUB1)/ 2)        ;    /*MIDPOINT BETWEEN POINTS */

YSUB1 =(TAN(60 / XCONST) * (LSUB3 / 2)) * (200 / 173.20);
/* HEIGHT OF NEW POINT */
/*X=1; Y=27; SIZE= 1; FUNCTION='LABEL'; COLOR='RED'; TEXT=XW; OUTPUT;*/

DATA ONE; SET RESULT; RUN;

DATA ANNO3  ;
INPUT  X Y FUNCTION $
SIZE COLOR $8. POSITION $1. XSYS $1. YSYS $1. HSYS $1. ANGLE ROTATE
STYLE $8. TEXT $30.;
DATALINES;
0   0   MOVE  . .       522  . . . .
50  100 DRAW  1 BLUE    522  . . . .
0   200 DRAW  1 BLUE    522  . . . .
-50 100 DRAW  1 BLUE    522  . . . .
0   0   DRAW  1 BLUE    522  . . . .
-45 110 MOVE  . .       522  . . . .
5   10  DRAW  1 BLUE    522  . . . .
-40 120 MOVE  . .       522  . . . .
10  20  DRAW  1 BLUE    522  . . . .
-35 130 MOVE  . .       522  . . . .
15  30  DRAW  1 BLUE    522  . . . .
-30 140 MOVE  . .       522  . . . .
20  40  DRAW  1 BLUE    522  . . . .
-25 150 MOVE  . .       522  . . . .
25  50  DRAW  1 BLUE    522  . . . .
-20 160 MOVE  . .       522  . . . .
30  60  DRAW  1 BLUE    522  . . . .
-15 170 MOVE  . .       522  . . . .
35  70  DRAW  1 BLUE    522  . . . .
-10 180 MOVE  . .       522  . . . .
40  80  DRAW  1 BLUE    522  . . . .
-05 190 MOVE  . .       522  . . . .
45  90  DRAW  1 BLUE    522  . . . .
45  110 MOVE  . .       522  . . . .
-5  10  DRAW  1 BLUE    522  . . . .
40  120 MOVE  . .       522  . . . .
-10 20  DRAW  1 BLUE    522  . . . .
35  130 MOVE  . .       522  . . . .
-15 30  DRAW  1 BLUE    522  . . . .
30  140 MOVE  . .       522  . . . .
-20 40  DRAW  1 BLUE    522  . . . .
25  150 MOVE  . .       522  . . . .
-25 50  DRAW  1 BLUE    522  . . . .
20  160 MOVE  . .       522  . . . .
-30 60  DRAW  1 BLUE    522  . . . .
15  170 MOVE  . .       522  . . . .
-35 70  DRAW  1 BLUE    522  . . . .
10  180 MOVE  . .       522  . . . .
-40 80  DRAW  1 BLUE    522  . . . .
5   190 MOVE  . .       522  . . . .
-45 90  DRAW  1 BLUE    522  . . . .
26.5 179   TEXT  1 RED     522 . . NONE    C
30.5 171   TEXT  1 RED     522 . . NONE    A
34.5 163   TEXT  1 RED     522 . . NONE    +
38.5 155   TEXT  1 RED     522 . . NONE    M
42.5 147   TEXT  1 RED     522 . . NONE    G
-43.5  139   TEXT  1 RED     522 . . NONE    S
-40  147   TEXT  1 RED     522 . . NONE    O
-36.5 155   TEXT  1 RED     522 . . NONE    4
-32.5 163   TEXT  1 RED     522 . . NONE    +
-29  171   TEXT  1 RED     522 . . NONE    C
-24.5 179   TEXT  1 RED     522 . . NONE    L
15   185   TEXT  1 GREEN   522 . . NONE    80
-15  185   TEXT  1 GREEN   522 . . NONE    80
25   165   TEXT  1 GREEN   522 . . NONE    60
-25  165   TEXT  1 GREEN   522 . . NONE    60
35   145   TEXT  1 GREEN   522 . . NONE    40
-35  145   TEXT  1 GREEN   522 . . NONE    40
45   125   TEXT  1 GREEN   522 . . NONE    20
-45  125   TEXT  1 GREEN   522 . . NONE    20
 ;

PROC SORT DATA=ONE OUT=OUTF1;
BY GROUP;
RUN;
DATA OUTF2; SET OUTF1;
BY GROUP;
FILE PRINT;
RETAIN COUNT 0;
IF FIRST.GROUP THEN DO;
   COUNT=COUNT+1;
END;
IF COUNT= 1 THEN DO;
   VAL1 = SD;
END;
IF COUNT= 2 THEN DO;
   VAL2 = SD;
END;
IF COUNT= 3 THEN DO;
   VAL3 = SD;
END;
IF COUNT= 4 THEN DO;
   VAL4 = SD;
END;
IF COUNT= 5 THEN DO;
   VAL5 = SD;
END;
IF COUNT= 6 THEN DO;
   VAL6 = SD;
END;
IF COUNT= 7 THEN DO;
   VAL7 = SD;
END;
IF COUNT= 8 THEN DO;
   VAL8 = SD;
END;
IF COUNT= 9 THEN DO;
   VAL9 = SD;
END;
IF COUNT= 10 THEN DO;
   VAL10 = SD;
END;
IF COUNT= 11 THEN DO;
   VAL11 = SD;
END;
IF COUNT= 12 THEN DO;
   VAL12 = SD;
END;
IF COUNT= 13 THEN DO;
   VAL13 = SD;
END;
IF COUNT= 14 THEN DO;
   VAL14 = SD;
END;
IF COUNT= 15 THEN DO;
   VAL15 = SD;
END;
IF COUNT= 16 THEN DO;
   VAL16 = SD;
END;
IF COUNT= 17 THEN DO;
   VAL17 = SD;
END;
IF COUNT= 18 THEN DO;
   VAL18 = SD;
END;
IF COUNT= 19 THEN DO;
   VAL19 = SD;
END;
IF COUNT= 20 THEN DO;
   VAL20 = SD;
END;
IF COUNT= 21 THEN DO;
   VAL21 = SD;
END;
IF COUNT= 22 THEN DO;
   VAL22 = SD;
END;
IF COUNT= 23 THEN DO;
   VAL23 = SD;
END;
IF COUNT= 24 THEN DO;
   VAL24 = SD;
END;
IF COUNT= 25 THEN DO;
   VAL25 = SD;
END;
IF COUNT= 26 THEN DO;
   VAL26 = SD;
END;
IF COUNT= 27 THEN DO;
   VAL27 = SD;
END;

PROC SORT DATA=OUTF2 OUT=OUTF2A;
BY GROUP;
RUN;

DATA ANNO4;
LENGTH TEXT $30 FUNCTION $8;
RETAIN FUNCTION 'TEXT'
       SIZE 1
       COLOR 'GREEN' STYLE 'NONE'
       POSITION '6' XSYS YSYS '2';
SET OUTF2A;
BY GROUP;
IF FIRST.GROUP THEN DO;
   TEXT=LOC;
   IF VAL1 >  0 THEN DO;
       X= 95;   Y=200;
   OUTPUT;
   TEXT='   ';
       X= 87;   Y=200;
   OUTPUT;
   END;
   IF VAL2 >= 0 THEN DO;
       X= 95;   Y=195;
   OUTPUT;
   TEXT='A =';
       X= 87;   Y=195;
   OUTPUT;
   END;
   IF VAL3 >= 0 THEN DO;
       X= 95;   Y=190;
   OUTPUT;
   TEXT='B =';
       X= 87;   Y=190;
   OUTPUT;
   END;
   IF VAL4 >= 0 THEN DO;
       X= 95;   Y=185;
   OUTPUT;
   TEXT='C =';
       X= 87;   Y=185;
   OUTPUT;
   END;
   IF VAL5 >= 0 THEN DO;
       X= 95;   Y=180;
   OUTPUT;
   TEXT='D =';
       X= 87;   Y=180;
   OUTPUT;
   END;
   IF VAL6 >= 0 THEN DO;
       X= 95;   Y=175;
   OUTPUT;
   TEXT='E =';
       X= 87;   Y=175;
   OUTPUT;
   END;
   IF VAL7 >= 0 THEN DO;
       X= 95;   Y=170;
   OUTPUT;
   TEXT='F =';
       X= 87;   Y=170;
   OUTPUT;
   END;
   IF VAL8 >= 0 THEN DO;
       X= 95;   Y=165;
   OUTPUT;
   TEXT='G =';
       X= 87;   Y=165;
   OUTPUT;
   END;
   IF VAL9 >= 0 THEN DO;
       X= 95;   Y=160;
   OUTPUT;
   TEXT='H =';
       X= 87;   Y=160;
   OUTPUT;
   END;
   IF VAL10 >= 0 THEN DO;
       X= 95;   Y=155;
   OUTPUT;
   TEXT='I =';
       X= 87;   Y=155;
   OUTPUT;
   END;
   IF VAL11 >= 0 THEN DO;
       X= 95;   Y=150;
   OUTPUT;
   TEXT='J =';
       X= 87;   Y=150;
   OUTPUT;
   END;
   IF VAL12 >= 0 THEN DO;
       X= 95;   Y=145;
   OUTPUT;
   TEXT='K =';
       X= 87;   Y=145;
   OUTPUT;
   END;
   IF VAL13 >= 0 THEN DO;
       X= 95;   Y=140;
   OUTPUT;
   TEXT='L =';
       X= 87;   Y=140;
   OUTPUT;
   END;
   IF VAL14 >= 0 THEN DO;
       X= 95;   Y=135;
   OUTPUT;
   TEXT='M =';
       X= 87;   Y=135;
   OUTPUT;
   END;
   IF VAL15 >= 0 THEN DO;
       X= 95;   Y=130;
   OUTPUT;
   TEXT='N =';
       X= 87;   Y=130;
   OUTPUT;
   END;
   IF VAL16 >= 0 THEN DO;
       X= 95;   Y=125;
   OUTPUT;
   TEXT='O =';
       X= 87;   Y=125;
   OUTPUT;
   END;
   IF VAL17 >= 0 THEN DO;
       X= 95;   Y=120;
   OUTPUT;
   TEXT='P =';
       X= 87;   Y=120;
   OUTPUT;
   END;
   IF VAL18 >= 0 THEN DO;
       X= 95;   Y=115;
   OUTPUT;
   TEXT='Q =';
       X= 87;   Y=115;
   OUTPUT;
   END;
   IF VAL19 >= 0 THEN DO;
       X= 95;   Y=110;
   OUTPUT;
   TEXT='R =';
       X= 87;   Y=110;
   OUTPUT;
   END;
   IF VAL20 >= 0 THEN DO;
       X= 95;   Y=105;
   OUTPUT;
   TEXT='S =';
       X= 87;   Y=105;
   OUTPUT;
   END;
   IF VAL21 >= 0 THEN DO;
       X= 95;   Y=100;
   OUTPUT;
   TEXT='T =';
       X= 87;   Y=100;
   OUTPUT;
   END;
   IF VAL22 >= 0 THEN DO;
       X= 95;   Y=95;
   OUTPUT;
   TEXT='U =';
       X= 87;   Y=95;
   OUTPUT;
   END;
   IF VAL23 >= 0 THEN DO;
       X= 95;   Y=90;
   OUTPUT;
   TEXT='V =';
       X= 87;   Y=90;
   OUTPUT;
   END;
   IF VAL24 >= 0 THEN DO;
       X= 95;   Y=85;
   OUTPUT;
   TEXT='W =';
       X= 87;   Y=85;
   OUTPUT;
   END;
   IF VAL25 >= 0 THEN DO;
       X= 95;   Y=80;
   OUTPUT;
   TEXT='X =';
       X= 87;   Y=80;
   OUTPUT;
   END;
   IF VAL26 >= 0 THEN DO;
       X= 95;   Y=75;
   OUTPUT;
   TEXT='Y =';
       X= 87;   Y=75;
   OUTPUT;
   END;
   IF VAL27 >= 0 THEN DO;
       X= 95;   Y=70;
   OUTPUT;
   TEXT='Z =';
       X= 87;   Y=70;
   OUTPUT;
   END;
END;

DATA ANNO5; SET ANNO3 ANNO4;
PROC SORT DATA=ANNO5 OUT=ANNO6;
BY GROUP;
RUN;
DATA ANNO6; SET ANNO6(KEEP=X Y FUNCTION SIZE COLOR POSITION
                           XSYS YSYS HSYS ANGLE ROTATE STYLE TEXT
                           GROUP);
RUN;

DATA ANNO7;
INPUT X Y FUNCTION $
SIZE COLOR $8. POSITION $1. XSYS $1. YSYS $1. HSYS $1. ANGLE ROTATE
STYLE $8. TEXT $30.;
DATALINES;
-100   200   TEXT   1 GREEN   622 . . NONE    TDS MG/L
-100   195   TEXT   1 GREEN   622 . . NONE    SCALE OF DIAMETERS
-100   175   TEXT   1 GREEN   622 . . NONE    1000 < TDS <= 10000
-100   130   TEXT   1 GREEN   622 . . NONE    500 < TDS <= 1000
-100   98    TEXT   1 GREEN   622 . . NONE    0 < TDS <= 500
;
DATA ANNO8; SET ANNO6 ANNO7;
PROC SORT DATA=ANNO8 OUT=ANNO8;
BY GROUP;
RUN;

TITLE C=BLACK;
TITLE6 F=NONE H=1 'BROWNING-FERRIS INDUSTRIES, INC.';
TITLE7 F=NONE H=1 'GROUNDWATER SERVICES / DATA SERVICES';
TITLE8 F=NONE H=1 "&SITE";
TITLE9 F=NONE H=1 "*************** TRILINEAR (PIPER) DIAGRAM ***************";
TITLE10 F=NONE H=1 'PERCENT OF TOTAL MILLIEQUIVALENTS PER LITER';
PROC GPLOT DATA=RESULT  ANNOTATE=ANNO8 GOUT=GRAPH1  ;
SYMBOL;
SYMBOL1  V=NONE    H=1 COLOR=WHITE;
SYMBOL2  V=A       H=1 COLOR=GREEN;
SYMBOL3  V=B       H=1 COLOR=GREEN;
SYMBOL4  V=C       H=1 COLOR=GREEN;
SYMBOL5  V=D       H=1 COLOR=GREEN;
SYMBOL6  V=E       H=1 COLOR=GREEN;
SYMBOL7  V=F       H=1 COLOR=GREEN;
SYMBOL8  V=G       H=1 COLOR=GREEN;
SYMBOL9  V=H       H=1 COLOR=GREEN;
SYMBOL10 V=I       H=1 COLOR=GREEN;
SYMBOL11 V=J       H=1 COLOR=GREEN;
SYMBOL12 V=K       H=1 COLOR=GREEN;
SYMBOL13 V=L       H=1 COLOR=GREEN;
SYMBOL14 V=M       H=1 COLOR=GREEN;
SYMBOL15 V=N       H=1 COLOR=GREEN;
SYMBOL16 V=O       H=1 COLOR=GREEN;
SYMBOL17 V=P       H=1 COLOR=GREEN;
SYMBOL18 V=Q       H=1 COLOR=GREEN;
SYMBOL19 V=R       H=1 COLOR=GREEN;
SYMBOL20 V=S       H=1 COLOR=GREEN;
SYMBOL21 V=T       H=1 COLOR=GREEN;
SYMBOL22 V=U       H=1 COLOR=GREEN;
SYMBOL23 V=V       H=1 COLOR=GREEN;
SYMBOL24 V=W       H=1 COLOR=GREEN;
SYMBOL25 V=X       H=1 COLOR=GREEN;
SYMBOL26 V=Y       H=1 COLOR=GREEN;
SYMBOL27 V=Z       H=1 COLOR=GREEN;
AXIS4 LABEL = NONE VALUE = NONE STYLE=0 MAJOR=NONE MINOR=NONE

  ORDER =  0 TO 200 BY 10 OFFSET = (0) LENGTH=4.7 IN ;
AXIS5 ORDER = -100 TO 100 BY 10  OFFSET =(0)  LENGTH=5.6 IN
      LABEL = NONE VALUE = NONE STYLE=0 MAJOR=NONE MINOR=NONE
                                        ;
 PLOT      YSUB1 * XSUB4=GROUP /       HAXIS=AXIS5 VAXIS=AXIS4
                               NOLEGEND ;
 BUBBLE2   YSUB1 * XSUB4=SD  / HAXIS=AXIS5 VAXIS=AXIS4 BSIZE=40 bcolor=red;
 RUN;

DATA DUMMY1;
INPUT X Y Z;
DATALINES;
0.8 4.7 10000
0.8 3.5 5000
0.8 2.7 1000
. . 284000
;
RUN;
TITLE;
PROC GPLOT DATA=DUMMY1 GOUT=GRAPH1;
AXIS1 ORDER=(0 TO 7);
BUBBLE Y * X = Z / HAXIS=AXIS1 VAXIS=AXIS1 BSIZE=40 NOAXIS BCOLOR=RED;
RUN;

 QUIT;
 GOPTIONS DISPLAY gsfname=out gsfmode=replace;

/* NOTE J=L F=SIMPLEX H=1 &XTEST1;*/

  PROC GREPLAY IGOUT=GRAPH1 GOUT=GRAPH1 NOFS;
     tc graph1;

tdef piper
     1/LLX=5   LLY=0
       ULX=5   ULY=50
       URX=55  URY=50
       LRX=55  LRY=0
       XLATEX=3.5
     2/LLX=40  LLY=0
       ULX=40  ULY=50
       URX=90  URY=50
       LRX=90  LRY=0
       XLATEX=1.5
     3/LLX=0   LLY=0
       ULX=0   ULY=100
       URX=100 URY=100
       LRX=100 LRY=0
       XLATEY=6.5
     4/LLX=0   LLY=0
       ULX=0   ULY=100
       URX=100 URY=100
       LRX=100 LRY=0;
   template piper;
goption display;
     TREPLAY 1:1 2:2 3:3 4:4;
run;
quit;