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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 664 views
  • 0 likes
  • 2 in conversation