/* COPYRIGHT 1996, SAS INSTITUTE INC. */ %annomac; /* include annotate macros from autocall macro library */ %global num_z yvalmin yvalmax ybyval; %MACRO PLOT3D( ds, /* input data set */ x, /* haxis variable */ y_a, /* first y variable */ y_b, /* second y variable */ y_c, /* third y variable */ z, /* the by variable */ xoffset, /* origin of the axes in percent of graph area in the x direction */ yoffset, /* origin of the axes in percent of graph area in the y direction */ xpermax, /* maximum length of the x-axis in percent of graph area */ ypermax, /* maximum length of the y-axis in percent of graph area */ xvalmin, /* minimum value for x */ yvalmin, /* minimum value for y */ xvalmax, /* maximum value for x */ yvalmax, /* maximum value for y */ xbyval, /* axis interval for x */ ybyval, /* axis interval for y */ barwidth, /* width of the plot line in percent of graph area */ lncolor1, /* color of first area under the curve */ lncolor2, /* color of second area under the curve */ lncolor3, /* color of third area under the curve */ areapat1, /* pattern of the first area under the curve */ areapat2, /* pattern of the second area under the curve */ areapat3, /* pattern of the third area under the curve */ tpcolor1, /* color of first plot line */ tpcolor2, /* color of second plot line */ tpcolor3, /* color of third plot line */ toppat1, /* pattern of the first line */ toppat2, /* pattern of the second line */ toppat3, /* pattern of the third line */ titleone, /* text of first title */ titletwo, /* text of second title */ legend, /* display a legend, yes or no */ leglabel, /* text of legend label */ legval1, /* first legend value */ legval2, /* second legend value */ legval3, /* third legend value */ vaxlabel, /* vaxis label */ haxlabel, /* haxis label */ area, /* areas under the curves, yes or no */ gridline, /* grid line style, 1-44 */ gridcolr, /* grid line color */ arealncl, /* color of lines in the area fill */ leftcolr, /* color of the left panel */ backcolr, /* color of the back panel */ botmcolr, /* color of the bottom panel */ leftfill, /* pattern fill of the left panel */ backfill, /* pattern fill of the back panel */ botmfill, /* pattern fill of the bottom panel */ titlcolr, /* title color */ axiscolr, /* axis color */ legncolr, /* legend color */ titlfont, /* title font */ axisfont, /* axis font */ legnfont, /* legend font */ leghorgn, /* origin of the legend in percent of graph area in the x direction */ legvorgn, /* origin of the legend in percent of graph area in the y direction */ libref, /* library reference for the gout catalog */ catalog, /* catalog reference for the gout catalog */ entry, /* entry name for the gout catalog */ xformat, /* format for the x variable */ yformat /* format for the y variable */ ); %if &z= %then %let z=1; %if &xpermax= %then %let xpermax=50; %if &ypermax= %then %let ypermax=40; %if &barwidth= %then %let barwidth=2; %if &lncolor1= %then %let lncolor1=black; %if &lncolor2= %then %let lncolor2=black; %if &lncolor3= %then %let lncolor3=black; %if &areapat1= %then %let areapat1=solid; %if &areapat2= %then %let areapat2=solid; %if &areapat3= %then %let areapat3=solid; %if &tpcolor1= %then %let tpcolor1=blue; %if &tpcolor2= %then %let tpcolor2=green; %if &tpcolor3= %then %let tpcolor3=red; %if &toppat1= %then %let toppat1=solid; %if &toppat2= %then %let toppat2=solid; %if &toppat3= %then %let toppat3=solid; %if &legend= %then %let legend=yes; %if &haxlabel= %then %let haxlabel=&x; %if &area= %then %let area=no; %if &gridline= %then %let gridline=3; %if &gridcolr= %then %let gridcolr=black; %if &arealncl= %then %let arealncl=black; %if &leftcolr= %then %let leftcolr=white; %if &backcolr= %then %let backcolr=white; %if &botmcolr= %then %let botmcolr=white; %if &leftfill= %then %let leftfill=empty; %if &backfill= %then %let backfill=empty; %if &botmfill= %then %let botmfill=empty; %if &titlcolr= %then %let titlcolr=black; %if &axiscolr= %then %let axiscolr=black; %if &legncolr= %then %let legncolr=black; %if &titlfont= %then %let titlfont=swiss; %if &axisfont= %then %let axisfont=swiss; %if &legnfont= %then %let legnfont=swiss; %if &legvorgn= %then %let legvorgn=7; %if &libref= %then %let libref=work; %if &catalog= %then %let catalog=gseg; %if &entry= %then %let entry=grseg; %if &xformat= %then %let xformat=8.; %if &yformat= %then %let yformat=8.; %macro count_zs; %if &y_b = %then %let num_z=1; %if (&y_b ne ) and (&y_c = ) %then %let num_z=2; %if (&y_b ne ) and (&y_c ne ) %then %let num_z=3; %mend count_zs; %count_zs; %if &num_z=1 %then %let xoffset=23; %if &num_z=1 %then %let yoffset=32; %if &num_z=1 %then %let leghorgn=45; %if &num_z=2 %then %let xoffset=20; %if &num_z=2 %then %let yoffset=30; %if &num_z=2 %then %let leghorgn=40; %if &num_z=3 %then %let xoffset=17; %if &num_z=3 %then %let yoffset=28; %if &num_z=3 %then %let leghorgn=35; %macro legvalue; %if (&leglabel=) %then %do; %if (&legend=yes) %then %let leglabel=LEGEND; %end; %if (&legval1=) %then %do; %if (&legend=yes) %then %let legval1=%upcase(&y_a); %end; %if (&legval2=) %then %do; %if (&legend=yes) %then %let legval2=%upcase(&y_b); %end; %if (&legval3=) %then %do; %if (&legend=yes) %then %let legval3=%upcase(&y_c); %end; %mend legvalue; %legvalue; %macro yminmax; proc means min max noprint data=&ds; var &y_a; output out=minmaxy1 min=ymin max=ymax; run; %if (&y_b ne ) %then %do; proc means min max noprint data=&ds; var &y_b; output out=minmaxy2 min=ymin max=ymax; run; %end; %if (&y_c ne ) %then %do; proc means min max noprint data=&ds; var &y_c; output out=minmaxy3 min=ymin max=ymax; run; %end; %if (&y_b ne ) and (&y_c ne ) %then %do; data minmax; set minmaxy1 minmaxy2 minmaxy3; run; %end; %else %if (&y_b ne ) and (&y_c = ) %then %do; data minmax; set minmaxy1 minmaxy2; run; %end; %else %do; data minmax; set minmaxy1; run; %end; proc means min max noprint data=minmax; var ymin; output out=outymin min=ymin; run; proc means min max noprint data=minmax; var ymax; output out=outymax max=ymax; run; data minmax; set outymin; set outymax; run; proc means min max noprint data=&ds; var &x; output out=xminmax max=xmax min=xmin; run; data _null_; length ymax 8 ymin 8 ybyval 8; set minmax; set xminmax; ymaxtest=10**-10; ymintest=-10**-10; if (ymax ge ymaxtest) and (ymin ge 0) then do; /* positive numbers */ do until (ymax le ymaxtest); ymaxtest=ymaxtest*10; end; ymax=ymaxtest; ymin=0; ybyval=ymax/10; end; if (ymax le 0) then do; /* negative numbers */ do until (ymin ge ymintest); ymintest=ymintest*10; end; ymin=ymintest; ymax=0; ybyval=abs(ymin/10); end; if (ymax > 0) and (ymin < 0) then do; /* positive and negative nums*/ do until (ymax le ymaxtest); ymaxtest=ymaxtest*10; end; do until (ymin >= ymintest); ymintest=ymintest*10; end; ymax=ymaxtest; ymin=ymintest; ybyval=(ymax-ymin)/10; end; call symput('ybyval',trim(left(put(ybyval,&yformat)))); call symput('yvalmin',trim(left(put(ymin,&yformat)))); call symput('yvalmax',trim(left(put(ymax,&yformat)))); %mend yminmax; %if (&yvalmin= ) or (&yvalmax= ) or (&ybyval= ) %then %yminmax; data _null_; xaxislen=&xpermax; yaxislen=&ypermax; ftcolor1="&tpcolor1"; ftcolor2="&tpcolor2"; ftcolor3="&tpcolor3"; call symput('xaxislen',xaxislen); call symput('yaxislen',yaxislen); call symput('ftcolor1',ftcolor1); call symput('ftcolor2',ftcolor2); call symput('ftcolor3',ftcolor3); run; proc sort data=&ds out=a_sorted; by &z; run; data b; keep &x &y_a &y_b &y_c &z x1_a y1_a x2_a y2_a x3_a y3_a x4_a y4_a x5_a y5_a x6_a y6_a x7_a y7_a x1_b y1_b x2_b y2_b x3_b y3_b x4_b y4_b x5_b y5_b x6_b y6_b x7_b y7_b x1_c y1_c x2_c y2_c x3_c y3_c x4_c y4_c x5_c y5_c x6_c y6_c x7_c y7_c; if &num_z = 1 then do; set a_sorted end=last; by &z; x1_a=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth; y1_a=(&y_a-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth; x2_a=(x1_a) + (&barwidth); y2_a=(y1_a) + (&barwidth); if upcase("&area") = 'YES' then do; x6_a=(x1_a); y6_a=(&yoffset+&barwidth); end; if last then do; x4_a=(x1_a); y4_a=(y1_a); x3_a=(x2_a); y3_a=(y2_a); if upcase("&area") = 'YES' then do; x5_a=(x6_a); y5_a=(y6_a); x7_a=(x5_a+&barwidth); y7_a=(y5_a+&barwidth); end; output; end; else do; set a_sorted end=last nobs=cnt; by &z; x4_a=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth; y4_a=(&y_a-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth; x3_a=(x4_a) + (&barwidth); y3_a=(y4_a) + (&barwidth); if upcase("&area") = 'YES' then do; x5_a=(x4_a); y5_a=(&yoffset+&barwidth); x6_a=(x1_a); y6_a=(&yoffset+&barwidth); end; if (last.&z) and (upcase("&area")='YES') then do; x7_a=(x5_a+&barwidth); y7_a=(y5_a+&barwidth); end; output; end; end; if &num_z = 2 then do; set a_sorted end=last; by &z; x1_a=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth; y1_a=(&y_a-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth; x1_b=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth*4; y1_b=(&y_b-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth*4; x2_a=(x1_a) + (&barwidth); y2_a=(y1_a) + (&barwidth); x2_b=(x1_b) + (&barwidth); y2_b=(y1_b) + (&barwidth); if upcase("&area") = 'YES' then do; x6_a=(x1_a); y6_a=(&yoffset+&barwidth); x6_b=(x1_b); y6_b=(&yoffset+&barwidth*4); end; if last then do; x4_a=(x1_a); y4_a=(y1_a); x3_a=(x2_a); y3_a=(y2_a); if upcase("&area") = 'YES' then do; x5_a=(x6_a); y5_a=(y6_a); x7_a=(x5_a+&barwidth); y7_a=(y5_a+&barwidth); end; x4_b=(x1_b); y4_b=(y1_b); x3_b=(x2_b); y3_b=(y2_b); if upcase("&area") = 'YES' then do; x5_b=(x6_b); y5_b=(y6_b); x7_b=(x5_b+&barwidth); y7_b=(y5_b+&barwidth); end; output; end; else do; set a_sorted end=last nobs=cnt; by &z; x4_a=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth; y4_a=(&y_a-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth; x4_b=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+(&barwidth*4); y4_b=(&y_b-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+(&barwidth*4); x3_a=(x4_a) + (&barwidth); y3_a=(y4_a) + (&barwidth); x3_b=(x4_b) + (&barwidth); y3_b=(y4_b) + (&barwidth); if upcase("&area") = 'YES' then do; x5_a=(x4_a); y5_a=(&yoffset+&barwidth); x5_b=(x4_b); y5_b=(&yoffset+&barwidth*4); x6_a=(x1_a); y6_a=(&yoffset+&barwidth); x6_b=(x1_b); y6_b=(&yoffset+&barwidth*4); end; if (last.&z) and (upcase("&area") = 'YES') then do; x7_a=(x5_a+&barwidth); y7_a=(y5_a+&barwidth); x7_b=(x5_b+&barwidth); y7_b=(y5_b+&barwidth); end; output; end; end; if &num_z = 3 then do; set a_sorted end=last; by &z; x1_a=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth; y1_a=(&y_a-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth; x1_b=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth*4; y1_b=(&y_b-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth*4; x1_c=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth*7; y1_c=(&y_c-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth*7; x2_a=(x1_a) + (&barwidth); y2_a=(y1_a) + (&barwidth); x2_b=(x1_b) + (&barwidth); y2_b=(y1_b) + (&barwidth); x2_c=(x1_c) + (&barwidth); y2_c=(y1_c) + (&barwidth); if upcase("&area")='YES' then do; x6_a=(x1_a); y6_a=(&yoffset+&barwidth); x6_b=(x1_b); y6_b=(&yoffset+&barwidth*4); x6_c=(x1_c); y6_c=(&yoffset+&barwidth*7); end; if last then do; x4_a=(x1_a); y4_a=(y1_a); x3_a=(x2_a); y3_a=(y2_a); if upcase("&area")='YES' then do; x5_a=(x6_a); y5_a=(y6_a); x7_a=(x5_a+&barwidth); y7_a=(y5_a+&barwidth); end; x4_b=(x1_b); y4_b=(y1_b); x3_b=(x2_b); y3_b=(y2_b); if upcase("&area")='YES' then do; x5_b=(x6_b); y5_b=(y6_b); x7_b=(x5_b+&barwidth); y7_b=(y5_b+&barwidth); end; x4_c=(x1_c); y4_c=(y1_c); x3_c=(x2_c); y3_c=(y2_c); if upcase("&area")='YES' then do; x5_c=(x6_c); y5_c=(y6_c); x7_c=(x5_c+&barwidth); y7_c=(y5_c+&barwidth); end; output; end; else do; set a_sorted end=last nobs=cnt; by &z; x4_a=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+&barwidth; y4_a=(&y_a-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth; x4_b=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+(&barwidth*4); y4_b=(&y_b-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+&barwidth*4; x4_c=(&x-&xvalmin)/(&xvalmax-&xvalmin)*&xpermax+&xoffset+(&barwidth*7); y4_c=(&y_c-&yvalmin)/(&yvalmax-&yvalmin)*&ypermax+&yoffset+(&barwidth*7); x3_a=(x4_a) + (&barwidth); y3_a=(y4_a) + (&barwidth); x3_b=(x4_b) + (&barwidth); y3_b=(y4_b) + (&barwidth); x3_c=(x4_c) + (&barwidth); y3_c=(y4_c) + (&barwidth); if upcase("&area")='YES' then do; x5_a=(x4_a); y5_a=(&yoffset+&barwidth); x5_b=(x4_b); y5_b=(&yoffset+&barwidth*4); x5_c=(x4_c); y5_c=(&yoffset+&barwidth*7); x6_a=(x1_a); y6_a=(&yoffset+&barwidth); x6_b=(x1_b); y6_b=(&yoffset+&barwidth*4); x6_c=(x1_c); y6_c=(&yoffset+&barwidth*7); end; if (last.&z) and (upcase("&area")='YES') then do; x7_a=(x5_a+&barwidth); y7_a=(y5_a+&barwidth); x7_b=(x5_b+&barwidth); y7_b=(y5_b+&barwidth); x7_c=(x5_c+&barwidth); y7_c=(y5_c+&barwidth); end; output; end; end; run; data anno; length function $ 8 color $ 8; drop &x; retain xsys ysys '3' size .2 when 'a' line 1 color 'blue' oldx3_a oldy3_a oldx4_a oldy4_a oldx5_a oldy5_a oldx3_b oldy3_b oldx4_b oldy4_b oldx5_b oldy5_b oldx3_c oldy3_c oldx4_c oldy4_c oldx5_c oldy5_c; set b nobs=cnt end=last; by &z; if &num_z = 1 then do; if (_n_ > 1) and (_n_ < (cnt+1) and (not first.&z)) then do; function='poly';x=oldx3_a;y=oldy3_a;style="&toppat1"; color="&tpcolor1"; output; function='polycont'; x=oldx4_a; y=oldy4_a; color='black'; output; function='polycont'; x=x1_a; y=y1_a; output; function='polycont'; x=x2_a; y=y2_a; output; /*newcode*/ function='poly'; x=oldx4_a; y=oldy4_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=oldx5_a; y=oldy5_a; color='black'; output; function='polycont'; x=x6_a; y=y6_a; output; function='polycont'; x=x1_a; y=y1_a; output; end; if _n_ < (cnt+1); function='poly'; x=x1_a; y=y1_a; style="&toppat1"; color="&tpcolor1"; output; function='polycont'; x=x2_a; y=y2_a; color='black'; output; function='polycont'; x=x3_a; y=y3_a; output; function='polycont'; x=x4_a; y=y4_a; output; /*newcode*/ function='poly'; x=x4_a; y=y4_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=x5_a; y=y5_a; color='black'; output; function='polycont'; x=x6_a; y=y6_a; output; function='polycont'; x=x1_a; y=y1_a; output; if last.&z then do; function='poly'; x=x7_a; y=y7_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=x5_a; y=y5_a; color='black'; output; function='polycont'; x=x4_a; y=y4_a; output; function='polycont'; x=x3_a; y=y3_a; output; end; oldx3_a=x3_a; oldy3_a=y3_a; oldx4_a=x4_a; oldy4_a=y4_a; oldx5_a=x5_a; oldy5_a=y5_a; end; if &num_z = 2 then do; if (_n_ > 1) and (_n_ < (cnt+1) and (not first.&z)) then do; function='poly';x=oldx3_b;y=oldy3_b;style="&toppat2"; color="&tpcolor2"; output; function='polycont'; x=oldx4_b; y=oldy4_b; color='black'; output; function='polycont'; x=x1_b; y=y1_b; output; function='polycont'; x=x2_b; y=y2_b; output; /*newcode for _b*/ function='poly'; x=oldx4_b; y=oldy4_b; style="&areapat2"; color="&lncolor2"; output; function='polycont'; x=oldx5_b; y=oldy5_b; color='black'; output; function='polycont'; x=x6_b; y=y6_b; output; function='polycont'; x=x1_b; y=y1_b; output; function='poly';x=oldx3_a;y=oldy3_a;style="&toppat1"; color="&tpcolor1"; output; function='polycont'; x=oldx4_a; y=oldy4_a; color='black'; output; function='polycont'; x=x1_a; y=y1_a; output; function='polycont'; x=x2_a; y=y2_a; output; /*newcode*/ function='poly'; x=oldx4_a; y=oldy4_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=oldx5_a; y=oldy5_a; color='black'; output; function='polycont'; x=x6_a; y=y6_a; output; function='polycont'; x=x1_a; y=y1_a; output; end; if _n_ < (cnt+1); function='poly'; x=x1_b; y=y1_b; style="&toppat2"; color="&tpcolor2"; output; function='polycont'; x=x2_b; y=y2_b; color='black'; output; function='polycont'; x=x3_b; y=y3_b; output; function='polycont'; x=x4_b; y=y4_b; output; /*newcode for _b*/ function='poly'; x=x4_b; y=y4_b; style="&areapat2"; color="&lncolor2"; output; function='polycont'; x=x5_b; y=y5_b; color='black'; output; function='polycont'; x=x6_b; y=y6_b; output; function='polycont'; x=x1_b; y=y1_b; output; /*newcode*/ function='poly'; x=x4_a; y=y4_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=x5_a; y=y5_a; color='black'; output; function='polycont'; x=x6_a; y=y6_a; output; function='polycont'; x=x1_a; y=y1_a; output; function='poly'; x=x1_a; y=y1_a; style="&toppat1"; color="&tpcolor1"; output; function='polycont'; x=x2_a; y=y2_a; color='black'; output; function='polycont'; x=x3_a; y=y3_a; output; function='polycont'; x=x4_a; y=y4_a; output; if last.&z then do; function='poly'; x=x7_b; y=y7_b; style="&areapat2"; color="&lncolor2"; output; function='polycont'; x=x5_b; y=y5_b; color='black'; output; function='polycont'; x=x4_b; y=y4_b; output; function='polycont'; x=x3_b; y=y3_b; output; function='poly'; x=x7_a; y=y7_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=x5_a; y=y5_a; color='black'; output; function='polycont'; x=x4_a; y=y4_a; output; function='polycont'; x=x3_a; y=y3_a; output; end; oldx3_a=x3_a; oldy3_a=y3_a; oldx4_a=x4_a; oldy4_a=y4_a; oldx5_a=x5_a; oldy5_a=y5_a; oldx3_b=x3_b; oldy3_b=y3_b; oldx4_b=x4_b; oldy4_b=y4_b; oldx5_b=x5_b; oldy5_b=y5_b; end; if &num_z = 3 then do; if (_n_ > 1) and (_n_ < (cnt+1) and (not first.&z)) then do; function='poly';x=oldx3_c;y=oldy3_c;style="&toppat3"; when='a'; color="&tpcolor3"; output; function='polycont'; x=oldx4_c; y=oldy4_c; color='black'; output; function='polycont'; x=x1_c; y=y1_c; output; function='polycont'; x=x2_c; y=y2_c; output; /*newcode for _c*/ function='poly'; x=oldx4_c; y=oldy4_c; style="&areapat3"; color="&lncolor3"; output; function='polycont'; x=oldx5_c; y=oldy5_c; color='black'; output; function='polycont'; x=x6_c; y=y6_c; output; function='polycont'; x=x1_c; y=y1_c; output; function='poly'; x=oldx4_c; y=oldy4_c; output; function='polycont'; x=oldx5_c; y=oldy5_c; color="&arealncl"; output; function='poly'; x=oldx4_c; y=oldy4_c; output; function='poly';x=oldx3_b;y=oldy3_b;style="&toppat2"; when='a'; color="&tpcolor2"; output; function='polycont'; x=oldx4_b; y=oldy4_b; color='black'; output; function='polycont'; x=x1_b; y=y1_b; output; function='polycont'; x=x2_b; y=y2_b; output; /*newcode for _b*/ function='poly'; x=oldx4_b; y=oldy4_b; style="&areapat2"; when='a'; color="&lncolor2"; output; function='polycont'; x=oldx5_b; y=oldy5_b; color='black'; output; function='polycont'; x=x6_b; y=y6_b; output; function='polycont'; x=x1_b; y=y1_b; output; function='poly'; x=oldx4_b; y=oldy4_b; output; function='polycont'; x=oldx5_b; y=oldy5_b; color="&arealncl"; output; function='poly'; x=oldx4_b; y=oldy4_b; output; function='poly';x=oldx3_a;y=oldy3_a;style="&toppat1"; when='a'; color="&tpcolor1"; output; function='polycont'; x=oldx4_a; y=oldy4_a; color='black'; output; function='polycont'; x=x1_a; y=y1_a; output; function='polycont'; x=x2_a; y=y2_a; output; /*newcode for _a*/ function='poly'; x=oldx4_a; y=oldy4_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=oldx5_a; y=oldy5_a; color='black'; output; function='polycont'; x=x6_a; y=y6_a; color='black'; output; function='polycont'; x=x1_a; y=y1_a; output; function='poly'; x=oldx4_a; y=oldy4_a; output; function='polycont'; x=oldx5_a; y=oldy5_a; color="&arealncl"; output; function='poly'; x=oldx4_a; y=oldy4_a; output; /*function='polycont'; x=x3_a; y=y3_a; output;*/ end; if _n_ < (cnt+1); function='poly'; x=x1_c; y=y1_c; style="&toppat3"; color="&tpcolor3"; output; function='polycont'; x=x2_c; y=y2_c; color='black'; output; function='polycont'; x=x3_c; y=y3_c; output; function='polycont'; x=x4_c; y=y4_c; output; /*newcode for _c*/ function='poly'; x=x4_c; y=y4_c; style="&areapat3"; color="&lncolor3"; output; function='polycont'; x=x5_c; y=y5_c; color='black'; output; function='polycont'; x=x6_c; y=y6_c; output; function='polycont'; x=x1_c; y=y1_c; output; /*newcode for _b*/ function='poly'; x=x4_b; y=y4_b; style="&areapat2"; color="&lncolor2"; output; function='polycont'; x=x5_b; y=y5_b; color='black'; output; function='polycont'; x=x6_b; y=y6_b; output; function='polycont'; x=x1_b; y=y1_b; output; function='poly'; x=x1_b; y=y1_b; style="&toppat2"; color="&tpcolor2"; output; function='polycont'; x=x2_b; y=y2_b; color='black'; output; function='polycont'; x=x3_b; y=y3_b; output; function='polycont'; x=x4_b; y=y4_b; output; /*newcode for _a*/ function='poly'; x=x4_a; y=y4_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=x5_a; y=y5_a; color='black'; output; function='polycont'; x=x6_a; y=y6_a; output; function='polycont'; x=x1_a; y=y1_a; output; function='poly'; x=x1_a; y=y1_a; style="&toppat1"; color="&tpcolor1"; output; function='polycont'; x=x2_a; y=y2_a; color='black'; output; function='polycont'; x=x3_a; y=y3_a; output; function='polycont'; x=x4_a; y=y4_a; output; if last.&z then do; function='poly'; x=x7_c; y=y7_c; style="&areapat3"; color="&lncolor3"; output; function='polycont'; x=x5_c; y=y5_c; color='black'; output; function='polycont'; x=x4_c; y=y4_c; output; function='polycont'; x=x3_c; y=y3_c; output; function='poly'; x=x7_b; y=y7_b; style="&areapat2"; color="&lncolor2"; output; function='polycont'; x=x5_b; y=y5_b; color='black'; output; function='polycont'; x=x4_b; y=y4_b; output; function='polycont'; x=x3_b; y=y3_b; output; function='poly'; x=x7_a; y=y7_a; style="&areapat1"; color="&lncolor1"; output; function='polycont'; x=x5_a; y=y5_a; color='black'; output; function='polycont'; x=x4_a; y=y4_a; output; function='polycont'; x=x3_a; y=y3_a; output; end; oldx3_a=x3_a; oldy3_a=y3_a; oldx4_a=x4_a; oldy4_a=y4_a; oldx5_a=x5_a; oldy5_a=y5_a; oldx3_b=x3_b; oldy3_b=y3_b; oldx4_b=x4_b; oldy4_b=y4_b; oldx5_b=x5_b; oldy5_b=y5_b; oldx3_c=x3_c; oldy3_c=y3_c; oldx4_c=x4_c; oldy4_c=y4_c; oldx5_c=x5_c; oldy5_c=y5_c; end; run; data anno1; length function color $ 8; retain xsys ysys '3' when 'b' line 1; /* Color and fill the left panel */ function='poly'; x=&xoffset; y=&yoffset; color="&leftcolr"; style="&leftfill"; output; function='polycont'; x=&xoffset; y=&ypermax + &yoffset; output; function='polycont'; x=(&xoffset) + (3*&barwidth*&num_z); y=(&ypermax) + &yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=(&xoffset) + (3*&barwidth*&num_z); y=&yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=&xoffset; y=&yoffset; output; /* Color and fill the back panel */ function='poly'; x=(&xoffset) + (3*&barwidth*&num_z); color="&backcolr"; y=&yoffset + (3*&barwidth*&num_z); style="&backfill"; output; function='polycont'; x=(&xoffset) + (3*&barwidth*&num_z); y=(&ypermax) + &yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=(&xpermax) + &xoffset + (3*&barwidth*&num_z); y=(&ypermax) + &yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=(&xpermax) + &xoffset + (3*&barwidth*&num_z); y=&yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=(&xoffset) + (3*&barwidth*&num_z); y=&yoffset + (3*&barwidth*&num_z); output; /* Color and fill the bottom panel */ function='poly'; x=&xoffset; y=&yoffset; color="&botmcolr"; style="&botmfill"; output; function='polycont'; x=(&xoffset) + (3*&barwidth*&num_z); y=&yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=(&xpermax) + &xoffset + (3*&barwidth*&num_z); y=&yoffset + (3*&barwidth*&num_z); output; function='polycont'; x=&xoffset + &xpermax; y=&yoffset; output; function='polycont'; x=&xoffset; y=&yoffset; output; /* Draw the angled grid lines on the left panel */ /* and the horizontal grid lines on the back panel */ line_cnt=1; do yval= &yvalmin to &yvalmax by &ybyval; if (line_cnt=1 or yval=&yvalmax) then do; line=1; color="&gridcolr"; end; else do; line=&gridline; color="&gridcolr"; end; line_cnt + 1; function='move'; x=(&xoffset); y=(yval-&yvalmin)/(&yvalmax-&yvalmin)*(&ypermax)+&yoffset; output; function='draw'; color="&gridcolr"; x=(&xoffset) + (3*&barwidth*&num_z); y=y + (3*&barwidth*&num_z); output; function='draw'; color="&gridcolr"; x=(&xoffset) + (3*&barwidth*&num_z) + (&xpermax); y=y; output; end; /* Draw the vertical grid line/s on the left panels */ do zval= 1 to &num_z; line=1; function='move'; x=(&xoffset) + (3*&barwidth*zval); y=(&yoffset) + (3*&barwidth*zval); output; function='draw'; color="&gridcolr"; x=x; y=y + (&ypermax); output; end; /* Draw the horizontal grid line/s on the bottom panel */ line=1; do zval= 1 to &num_z; function='move'; x=(&xoffset) + (3*&barwidth*zval); y=(&yoffset) + (3*&barwidth*zval); output; function='draw'; color="&gridcolr"; x=x + (&xpermax); y=y; output; end; /* Draw the angled line on the right side of the bottom panel */ /* and the vertical line on the right side of the back panel */ line=1; function='move'; x=&xpermax + &xoffset; y=&yoffset; output; function='draw'; color="&gridcolr"; x=&xpermax + (3*&barwidth*&num_z) + &xoffset; y=&yoffset + (3*&barwidth*&num_z); output; function='draw'; color="&gridcolr"; x=x; y=y + (&ypermax); output; /*Draw a border around the graph area function='move'; x=1; y=1; output; function='draw'; x=1; y=99; color='blue'; output; function='draw'; x=99; y=99; output; function='draw'; x=99; y=1; output; function='draw'; x=1; y=1; output; Label the borders with percentages of the graph area function='label'; x=3; y=10; text='10'; output; function='label'; x=3; y=20; text='20'; output; function='label'; x=3; y=30; text='30'; output; function='label'; x=3; y=40; text='40'; output; function='label'; x=3; y=50; text='50'; output; function='label'; x=3; y=60; text='60'; output; function='label'; x=3; y=70; text='70'; output; function='label'; x=3; y=80; text='80'; output; function='label'; x=3; y=90; text='90'; output; function='label'; x=3; y=98; text='99'; output; function='label'; y=3; x=10; text='10'; output; function='label'; y=3; x=20; text='20'; output; function='label'; y=3; x=30; text='30'; output; function='label'; y=3; x=40; text='40'; output; function='label'; y=3; x=50; text='50'; output; function='label'; y=3; x=60; text='60'; output; function='label'; y=3; x=70; text='70'; output; function='label'; y=3; x=80; text='80'; output; function='label'; y=3; x=90; text='90'; output; function='label'; y=3; x=98; text='99'; output; */ if &num_z = 1 then do; xsys='3'; ysys='3'; function='label'; color="&legncolr"; x=&leghorgn; y=&legvorgn; style='swissb'; text="&leglabel" || ':' || ' ' || "&legval1"; output; function='move'; x=&leghorgn+length("&leglabel")+length("&legval1")-4; y=&legvorgn-2; output; function='bar'; x=x+2; y=y+2.75; style="&toppat1"; color="&tpcolor1"; line=0; output; end; if &num_z = 2 then do; xsys='3'; ysys='3'; function='label'; color="&legncolr"; x=&leghorgn; y=&legvorgn; style='swissb'; text="&leglabel" || ':' || ' ' || "&legval1"; output; function='move'; x=&leghorgn+length("&leglabel")+length("&legval1")-4; y=&legvorgn-2; output; function='bar'; x=x+2; y=y+2.75; style="&toppat1"; color="&tpcolor1"; line=0; output; function='label'; color="&legncolr"; x=x+5; y=&legvorgn; style='swissb'; text="&legval2"; output; function='move'; x=x+length("&legval2")-2; y=&legvorgn-2; output; function='bar'; x=x+2; y=y+2.75; style="&toppat2"; color="&tpcolor2"; line=0; output; end; if &num_z = 3 then do; xsys='3'; ysys='3'; function='label'; color="&legncolr"; x=&leghorgn; y=&legvorgn; style='swissb'; text="&leglabel" || ':' || ' ' || "&legval1"; output; function='move'; x=&leghorgn+length("&leglabel")+length("&legval1")-4; y=&legvorgn-2; output; function='bar'; x=x+2; y=y+2.75; style="&toppat1"; color="&tpcolor1"; line=0; output; function='label'; color="&legncolr"; x=x+5; y=&legvorgn; style='swissb'; text="&legval2"; output; function='move'; x=x+length("&legval2")-2; y=&legvorgn-2; output; function='bar'; x=x+2; y=y+2.75; style="&toppat2"; color="&tpcolor2"; line=0; output; function='label'; color="&legncolr"; x=x+5; y=&legvorgn; style='swissb'; text="&legval3"; output; function='move'; x=x+length("&legval3")-3; y=&legvorgn-2; output; function='bar'; x=x+2; y=y+2.75; style="&toppat3"; color="&tpcolor3"; line=0; output; end; run; goptions ctext=&axiscolr; axis1 order=(&xvalmin to &xvalmax by &xbyval) label=(f=swissb "&haxlabel") offset=(0,0)pct length=&xaxislen pct origin=(&xoffset,&yoffset)pct value=(f=swissb) minor=none; axis2 order=(&yvalmin to &yvalmax by &ybyval) offset=(0,0)pct length=&yaxislen pct origin=(&xoffset,&yoffset)pct label=(f=swissb a=-90 r=90 "&vaxlabel") value=(f=swissb); symbol1 i=none v=none; symbol2 i=none v=none; symbol3 i=none v=none; title1 c=&titlcolr h=2 f=swissb " &titleone"; title2 c=&titlcolr h=1 f=swissb " &titletwo"; proc gplot data=a_sorted nocache anno=anno1 gout=&libref..&catalog; by &z; %macro plotit; %if &num_z=1 %then %do; plot &y_a*&x / haxis=axis1 vaxis=axis2 anno=anno ctext=&axiscolr caxis=&axiscolr name="&entry"; run; quit; %end; %if &num_z=2 %then %do; plot &y_a*&x &y_b*&x / overlay haxis=axis1 vaxis=axis2 anno=anno ctext=&axiscolr caxis=&axiscolr name="&entry"; run; quit; %end; %if &num_z=3 %then %do; plot &y_a*&x &y_b*&x &y_c*&x / overlay haxis=axis1 vaxis=axis2 anno=anno ctext=&axiscolr caxis=&axiscolr name="&entry"; run; quit; %end; %mend plotit; %plotit; dm log 'color data green' graph1; data _null_; put 'NOTE : ds resolves to:' "&ds"; put 'NOTE : x resolves to:' "&x"; put 'NOTE : y_a resolves to:' "&y_a"; put 'NOTE : y_b resolves to:' "&y_b"; put 'NOTE : y_c resolves to:' "&y_c"; put 'NOTE : z resolves to:' "&z"; put 'NOTE : xoffset resolves to:' "&xoffset"; put 'NOTE : yoffset resolves to:' "&yoffset"; put 'NOTE : xpermax resolves to:' "&xpermax"; put 'NOTE : ypermax resolves to:' "&ypermax"; put 'NOTE : xvalmin resolves to:' "&xvalmin"; put 'NOTE : yvalmin resolves to:' "&yvalmin"; put 'NOTE : xvalmax resolves to:' "&xvalmax"; put 'NOTE : yvalmax resloves to:' "&yvalmax"; put 'NOTE : xbyval resolves to:' "&xbyval"; put 'NOTE : ybyval resolves to:' "&ybyval"; put 'NOTE : barwidth resolves to:' "&barwidth"; put 'NOTE : lncolor1 resolves to:' "&lncolor1"; put 'NOTE : lncolor2 resolves to:' "&lncolor2"; put 'NOTE : lncolor3 resolves to:' "&lncolor3"; put 'NOTE : areapat1 resolves to:' "&areapat1"; put 'NOTE : areapat2 resolves to:' "&areapat2"; put 'NOTE : areapat3 resolves to:' "&areapat3"; put 'NOTE : tpcolor1 resolves to:' "&tpcolor1"; put 'NOTE : tpcolor2 resolves to:' "&tpcolor2"; put 'NOTE : tpcolor3 resolves to:' "&tpcolor3"; put 'NOTE : toppat1 resolves to:' "&toppat1"; put 'NOTE : toppat2 resolves to:' "&toppat2"; put 'NOTE : toppat3 resolves to:' "&toppat3"; put 'NOTE : titleone resolves to:' "&titleone"; put 'NOTE : titletwo resolves to:' "&titletwo"; put 'NOTE : legend resolves to:' "&legend"; put 'NOTE : leglabel resolves to:' "&leglabel"; put 'NOTE : legval1 resolves to:' "&legval1"; put 'NOTE : legval2 resolves to:' "&legval2"; put 'NOTE : legval3 resolves to:' "&legval3"; put 'NOTE : vaxlabel resolves to:' "&vaxlabel"; put 'NOTE : haxlabel resolves to:' "&haxlabel"; put 'NOTE : area resolves to:' "&area"; put 'NOTE : gridline resolves to:' "&gridline"; put 'NOTE : gridcolr resolves to:' "&gridcolr"; put 'NOTE : arealncl resolves to:' "&arealncl"; put 'NOTE : leftcolr resolves to:' "&leftcolr"; put 'NOTE : backcolr resolves to:' "&backcolr"; put 'NOTE : botmcolr resolves to:' "&botmcolr"; put 'NOTE : leftfill resolves to:' "&leftfill"; put 'NOTE : backfill resolves to:' "&backfill"; put 'NOTE : botmfill resolves to:' "&botmfill"; put 'NOTE : titlcolr resolves to:' "&titlcolr"; put 'NOTE : axiscolr resolves to:' "&axiscolr"; put 'NOTE : legncolr resolves to:' "&legncolr"; put 'NOTE : titlfont resolves to:' "&titlfont"; put 'NOTE : axisfont resolves to:' "&axisfont"; put 'NOTE : legnfont resolves to:' "&legnfont"; put 'NOTE : leghorgn resolves to:' "&leghorgn"; put 'NOTE : legvorgn resolves to:' "&legvorgn"; run; %MEND PLOT3D;