BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bearda
Obsidian | Level 7

Hi,

 

I'm struggling with a quite simple issue.

 

As an example I'm using:

https://documentation.sas.com/?docsetId=grstatgraph&docsetTarget=n11ergda33xtlwn1rdkbl1crim9n.htm&do...

 

What I want to achieve is to move continuouslegend to the left side and also title and values to left side of the legend.

 

Final image should look like this:

sas_legend_issue.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Try some combination of a LAYOUT LATTICE and a SIDEBAR. This isn't perfect, but maybe it will give you some ideas to pursue:

 

proc template;
define statgraph attrmap;
  begingraph;
    entrytitle "Height and Weight Distribution" ;

    /* Define the attribute map and assign the name "densityrange." */
    rangeattrmap name="densityrange" ;
      range MIN - 0.0004     / rangealtcolor=blue ;
      range 0.0004 < - 0.0014 / rangealtcolormodel=(lightpurple lightred) ;
      range 0.0014 < - 0.002  / rangealtcolor=red ;
    endrangeattrmap ;

    /* Associate the attribute map with input data column Density and
       assign variable name RANGEVAR to the named association */
    rangeattrvar attrvar=rangevar var=density attrmap="densityrange" ;

    /* Reference RANGEVAR in the SCATTTERPLOT statement */
    layout lattice / columns=2 columnweights=(0.1 0.9);
       sidebar / align=left;
           entry halign=left "Density" / rotate=90 ;
       endsidebar;
      continuouslegend "scatter" / orient=vertical
        halign=left title="";
      scatterplot x=height y=weight / markercolorgradient=rangevar
        markerattrs=(symbol=squarefilled size=6px) name="scatter";
    endlayout;
  endgraph;
end;

ods graphics / reset width=475px;
proc sgrender data=sashelp.gridded(where=(count>0)) template=attrmap;
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Try some combination of a LAYOUT LATTICE and a SIDEBAR. This isn't perfect, but maybe it will give you some ideas to pursue:

 

proc template;
define statgraph attrmap;
  begingraph;
    entrytitle "Height and Weight Distribution" ;

    /* Define the attribute map and assign the name "densityrange." */
    rangeattrmap name="densityrange" ;
      range MIN - 0.0004     / rangealtcolor=blue ;
      range 0.0004 < - 0.0014 / rangealtcolormodel=(lightpurple lightred) ;
      range 0.0014 < - 0.002  / rangealtcolor=red ;
    endrangeattrmap ;

    /* Associate the attribute map with input data column Density and
       assign variable name RANGEVAR to the named association */
    rangeattrvar attrvar=rangevar var=density attrmap="densityrange" ;

    /* Reference RANGEVAR in the SCATTTERPLOT statement */
    layout lattice / columns=2 columnweights=(0.1 0.9);
       sidebar / align=left;
           entry halign=left "Density" / rotate=90 ;
       endsidebar;
      continuouslegend "scatter" / orient=vertical
        halign=left title="";
      scatterplot x=height y=weight / markercolorgradient=rangevar
        markerattrs=(symbol=squarefilled size=6px) name="scatter";
    endlayout;
  endgraph;
end;

ods graphics / reset width=475px;
proc sgrender data=sashelp.gridded(where=(count>0)) template=attrmap;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 988 views
  • 0 likes
  • 2 in conversation