Hi.
I created a hbar graph with proc gchart. I created dataset sas for annotate labels, but it generate strange error.
This is my code:
data anlabels2(drop=periodo de_risk_class2 valore id_periodo);
length text $ 20 periodo $ 15;
retain function 'label' style 'Albany AMT/bo' when 'a' xsys ysys '2' hsys '3' size 3 position '>' color 'black';
set abc_report3_g2;
format periodo $15.;
midpoint=periodo; group=de_risk_class2;
text=left(put(abs(valore), commax20.2));
output;
run;
options ps=100;
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
pattern1 color='#7f8eb8';
pattern2 color='#fee97f';
pattern3 color='#e0efff';
goptions device=png nodisplay xpixels=1024 ypixels=500;
axis1 value=none label=none;
axis2 label=none value=(font='Albany AMT/bo' JUSTIFY=RIGHT);
axis4 label=none value=(font='Albany AMT/bo');
legend2 frame label=("Periodo");
goptions display;
/* Close the listing destination */
ods listing close;
/* This sample writes its output to C:\TEMP */
/* when run on the Windows operating system. */
/* Modify the destination for the PATH= */
/* option below if you want to write the */
/* output to a location other than C:\TEMP */
/* or if you are running on an operating */
/* system other than Windows. */
/* Open the HTML destination */
ods html path="&path.img/" (url=none) file="ReportSlide1.html";
proc catalog catalog=grafico2 kill force;
run;
/* Create the graphics output */
proc gchart data=work.abc_report3_g2 gout=work.grafico2;
format valore commax20.2;
format periodo $15.;
hbar3d periodo
/ discrete
sumvar=valore
SHAPE=cylinder
patternid=midpoint
group=de_risk_class2
name='ReportSlide2_prova'
maxis=axis1
raxis=axis4
gaxis=axis2
legend=legend1
nostats
annotate=anlabels2;
;
run;
quit;
ods html close;
ods listing;
Input dataset for anlabels2 and proc gchart is the same, but in log I get this note:
NOTE: PROBLEM IN OBSERVATION 7 -
DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'MIDPOINT'
SUPERMON: Exit GANOERR errors = 7
SUPERMON: Transform GCHARTDATA
SUPERMON: Vertical percentage requested
SUPERMON: derived x( . ), y(0.000)
SUPERMON: function exit xlast(0.000),ylast(0.000)
-------------------------------------------------
NOTE: ANNOTATE DEBUG OUTPUT FOLLOWS
INPUT VARIABLES AFTER FUNCTION LABEL WAS EXECUTED :
X .
Y 0.00000
Z .
XLAST 0.00000
YLAST 0.00000
XLSTT 0.00000
YLSTT 0.00000
XCNTR 0.00000
YCNTR 0.00000
XRAD 0.00000
SIZE 3.00000
ANGLE 0.00000
ROTATE 0.00000
SYSTEMS XSYS YSYS ZSYS HSYS
2 2 2 3
LINE 1
COLOR black
STYLE HWSYS001
WHEN A
POSITION >
STACK 0
-------------------------------------------------
SUPERMON: processing label function
SUPERMON: input x( . ), y( . )
-------------------------------------------------
NOTE: ANNOTATE DEBUG OUTPUT FOLLOWS
INPUT VARIABLES BEFORE FUNCTION LABEL WAS EXECUTED :
X .
Y .
Z .
XLAST 0.00000
YLAST 0.00000
XLSTT 0.00000
YLSTT 0.00000
XCNTR 0.00000
YCNTR 0.00000
XRAD 0.00000
SIZE 3.00000
ANGLE 0.00000
ROTATE 0.00000
SYSTEMS XSYS YSYS ZSYS HSYS
2 2 2 3
LINE 1
COLOR black
STYLE HWSYS001
WHEN A
POSITION >
STACK 0
-------------------------------------------------
SUPERMON: Both horizontal and vertical values requested
SUPERMON: enter GANOERR ERROR( 20), ERRSTR()
The result is that I don't have any labels on my graph. What's the matter?
hi ... first, you'd get a LOT more attention for this question on the SAS/GRAPH AND ODS GRAPHICS community page
second, I think you need a value for X in the annotate data set ... where does the label go along the x-axis
you have a value for midpoint and group and they position the label on the y-axis on a horizontal bar chart
your SUMVAR is VALORE, so have you tried adding
x = valore;
to the data step that creates the annotate data set
here's a stripped down version of your SAS code that uses SASHELP.CLASS to produce a chart ... all I added to thet the annotate data set is the variable X
it produced the attached chart (doesn't show anything useful but it did work)
proc summary data=sashelp.class nway;
class sex age;
var weight;
output out=stats sum=;
run;
data anlabels2;
length text $ 20 ;
retain function 'label' style '"Albany AMT/bo"' when 'a' xsys ysys '2'
hsys '3' size 3 position '6' color 'black';
set stats;
midpoint=age;
group=sex;
text=cat(weight);
x = weight;
run;
goptions reset=all;
proc gchart data=sashelp.class;
hbar3d age / discrete
sumvar=weight
SHAPE=cylinder
patternid=midpoint
group=sex
nostats
annotate=anlabels2;
run;
quit;
ps not sure what all your annotate errors mean
It looks like you are missing X, Y, and/or Z values on a couple of lines where you are calling the LABEL function. Look at the 7th obseravation (record) in your annotate dataset.
I just try to insert x, y, z values but I obtain same error for all records (I've pasted only line 7, but that error appears for all 13 lines of my table).
I try to add "x=valore;" but I have same error. I think that the problem is that Periodo is alphanumeric, so as de_risk_class2.
hi ... it's OK that the two variables are character variables (in the example I posted, the group variable SEX is a character variable)
you do not need X, Y, and Z ... if you look at the exmaple I posted, I just have MIDPOINT, GROUP, and X and get annotate labels placed on the chart
at this point, I think that the only way you'll get some meaningful help with this is (if the data set is small enough) to attach you data set to a postinh so others can give it a try
I add x=valore; and y=0; and now it's ok. Thanks.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.