@MingC wrote:
@FreelanceReinh , thank you very much for your quick and detailed response. I was wondering if I there is a proc template options could fix the alignment, which bothered me in the past couple of weeks. After I tried your idea to add 'A0A0A0A0A0'x to the end of shorter label value, I can left-align the label now.
You're welcome. There doesn't seem to be a PROC TEMPLATE option to control that alignment. Glad to hear that the 'A0'x trick worked for you. (The minor imperfection in the alignment shown in your screenshot is due to the proportional font you are using.)
Another approach would be SG annotation. Continuing the example from the previous post:
%sganno;
data anno;
%sgtext(reset=all, id="xtlabel", label="EDU", textcolor="GraphData1:contrastcolor", textsize=9, textweight="bold",
x1=0, x1space="layoutpixel", y1=69, y1space="layoutpixel", anchor="left");
%sgtext(label="CONSUMER", textcolor="GraphData2:contrastcolor", width=90, y1=55);
run;
proc template;
define statgraph axistable;
begingraph;
entrytitle "Average Product Sales By Division and Country";
layout overlay / cycleattrs=true pad=(left=18px)
yaxisopts=(offsetmax=0.15 label="Sales By Country");
innermargin / align=bottom opaque=true backgroundcolor=cxf5f5f5;
axistable x=product value=actual /
name="division" stat=mean display=(values)
headerlabel="Sales By Division"
headerlabelattrs=GraphLabelText
valueattrs=(size=9pt weight=bold)
colorgroup=division class=division;
endinnermargin;
barchart category=product y=actual / name="country"
barlabel=true barlabelformat=dollar5.0
stat=mean group=country groupdisplay=cluster;
discretelegend "country" / title="Country:" location=inside
valign=top;
annotate / ID="xtlabel";
endlayout;
endgraph;
end;
run;
proc sgrender data=have template=axistable sganno=anno;
run;
The display=(values) option in the AXISTABLE statement suppresses the original labels, which are then replaced by the labels (here: hard-coded) in the annotation dataset ANNO. The new pad= option of the LAYOUT statement provides the space on the left needed for those labels. Their vertical positioning (i.e., determining the y1 coordinates) is cumbersome.
Result:
Using SG annotation
... View more