BookmarkSubscribeRSS Feed
MingC
New User | Level 1

When I'm creating a x-axis table using GTL axistable statement in a layout overlay statement, I find the  x-axis table label (see below part marked as yellow) could not align, I tried to use labelhalign=left or labeljustify=left, but in vain. I also tried tickvaluehalign=left, but doesn't work.Any help are appreciated.  

MingC_1-1757317032795.png

 

proc template;
    define statgraph lineplot;
    begingraph/attrpriority=none datacontrastcolors=(red blue orange);
 
    entrytitle halign=left "&cat."/  textattrs=(size=8) ;
                          
     layout lattice / columns=1 rows=3 rowweights=(0.87 0.03 0.1) columndatarange=union rowdatarange=union;
  
        *cell with line plot;
        layout overlay / yaxisopts=(type=log logopts=(base=2 tickintervalstyle=logexpand
                           tickvaluelist=(32 64 256 1024 4096 16384 65536 262144 1048576 /*4194304 16777216*/) tickvaluepriority=true )
                           label="Median titre" labelattrs=(size=9pt) tickvalueattrs=(size=8pt))
                        xaxisopts=(display=(TICKS TICKVALUES LABEL line) label="Timepoint" labelattrs=(size=9pt) tickvalueattrs=(size=8pt));
 
           seriesplot  x=avisit_wk y=_median / group = AVALCAT display=all groupdisplay = cluster clusterwidth = 0.2 name = 'series';                       
           scatterplot x=avisit_wk y=_median /yerrorlower=_q1 yerrorupper=_q3
             ERRORBARATTRS=(pattern=dot) group = AVALCAT groupdisplay = cluster clusterwidth = 0.2 ;                           
                                                                       
           discretelegend "series" / title='' titleattrs=(size=9pt) valueattrs=(size=9pt)
                                  displayclipped = true across=4 border=false location=outside halign=center valign=bottom;
        endlayout;
               
       *cell with axistable values (n);
         layout overlay ;
            entry halign=left "n"/textattrs=(size=9pt);
         endlayout;
                     
        layout overlay / walldisplay=none halign=left xaxisopts=(tickvalueattrs=(size=8pt) display=none)
                                   /*yaxisopts=(display=(tickvalues ) tickvaluehalign=left)*/;
           axistable x=avisit_wk value=n /display=(label) /*labelhalign=left labeljustify=left*/ valueattrs=(size=9pt) labelattrs=(size=9pt) 
class=AVALCAT colorgroup=AVALCAT;         endlayout;                                               endlayout;     endgraph;   end; run; ods graphics on/noborder;   ods noptitle;

 

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @MingC and welcome to the SAS Support Communities!

 


@MingC wrote:

(...) I tried to use labelhalign=left or labeljustify=left, but in vain.


Sadly, the documentation of both these options says:

Restriction This option applies only to Y-axis tables.

@MingC wrote:

I also tried tickvaluehalign=left, but doesn't work.


I think this option does not apply to the axis table.

Unless someone else has a better idea, here is a workaround: Use a non-proportional (a.k.a. fixed-width) font for the labels to be left-aligned and pad the shorter labels with trailing non-breaking spaces so that they match the length of the longest label.

 

Example:

 

data have;
set sashelp.prdsale;
if division=:'E' then division='EDU';
run;

Using the PROC TEMPLATE example code from the AXISTABLE documentation, the x-axis table obtained with

proc sgrender data=have template=axistable;
run;

looks like this:

Default alignmentDefault alignment

After inserting the below LABELATTRS= option into the AXISTABLE statement of the PROC TEMPLATE code

...
headerlabelattrs=GraphLabelText
labelattrs=(family='Lucida Console' size=11pt)
valueattrs=(size=9pt weight=bold)
...

and modifying the short "EDU" value,

data want;
set have;
if division='EDU' then division='EDU'||'A0A0A0A0A0'x;
run;

proc sgrender data=want template=axistable;
run;

left-alignment is achieved:

Left-alignedLeft-aligned

MingC
New User | Level 1

@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. I'll accept your idea as solution if no better idea appears in one month.

MingC_0-1757383624272.png

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 197 views
  • 1 like
  • 2 in conversation