Data visualization with SAS programming

Separator bars in a datalattice

Occasional Contributor
Posts: 16

Separator bars in a datalattice

I would like to insert these separator bars into an existing graph produced using proc template with a layout datalattice to get two different x-axis variables.  I have tried using a reference line at x=0 for the middle and right side graph but that distorts the tick mark spacing along the x-axis.  Can you offer any suggestions on how this might be accomplished?

graph.JPGThank you for your help.

Esteemed Advisor
Posts: 6,877

Separator bars in a datalattice

Couldn't you just use annotate to add the desired grey lines?  For example code take a look at:

SAS Employee
Posts: 963

Separator bars in a datalattice

Art - (almost) all of my examples use the traditional SAS/Graph procs.

Unfortunately the new GTL-based procs (proc template, etc) would not be able to leverage any of my traditional code or the "tricks" that I typically use to customize my graphs.

Posts: 1,041

Separator bars in a datalattice

DataLattice normally draws outlines around the cells tha the cell headers.  So, you have already used the options to suppress this.  DataLattice supports COLUMNGUTTER=value.  You can use this to increase separation betrween the cells (unless you want the appearance of a continuous X axis line).  Which SAS 9.2 maintenance release are you using  (TS2 M?) ?

Occasional Contributor
Posts: 16

Separator bars in a datalattice

Thank you Sanjay.  Once I have the gap between graphs created by setting a columngutter, is there any way I can fill it with a colored bar as in the original example?

I am using TS2 M0.

Ideally I would like to maintain the appearance of a continuous x-axis (instead of breaking into 3 "separate" graphs) with separator bars, but if it is not possible in the installed release of SAS then I am open to exploring other possibilities.

Posts: 1,041

Re: Separator bars in a datalattice

Using the natural behavior of DATALATTICE in GTL (or PROC SGPANEL), you get the graph shown earlier.  That will work without special intervention for different data. 

No, you cannot color just the gutter in a different color.  However, you can achieve most of the look you want by using a UDF with the data and customizing the graph as shown below.  I cannot think of a way to extend the reference lines in to area below the X axis.


proc format;

  value grid

    1,5,9 ='XXX'



    other=' ';


data grid2;

  format cat grid.;

  do Cat=1 to 11;

    if cat=4 or cat=8 then do;

      value=.; upper=.; lower=.;


    else do;








proc print;run;

ods listing;

ods graphics / reset width=6in height=4in imagename='Grid_Plot';

proc sgplot data=grid2;

  scatter x=cat y=value / yerrorupper=upper yerrorlower=lower;

  refline 0;

  refline 4 8 / axis=x lineattrs=(thickness=10) transparency=0.7;

  xaxis label='Peak FEV1                           12 Hour FEV1                           24 Hour FEV1'

        values=(1 2 3 5 6 7 9 10 11) offsetmin=0.08 offsetmax=0.08;

  yaxis label='Treatment Difference of LS Mean and 95% CL (ml)';


Post a Question
Discussion Stats
  • 5 replies
  • 4 in conversation