BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

The type= option of the keylegend statement allow to keep a subset of the symbol used on the graph.

In the example, a filled symbol is used. It is always possible to resize the rectangle in the legend using scale, fillheigh, fillaspact.

However it is not possible to use these options to resize the symbol. Is there any other option which could be used.

 

Note: An alternative solution would be to create a specific legenditem only for the symbol (no color).

But here I'm just checking on whether I have missed an option.

 

proc sgplot data=sashelp.class;
    scatter x=weight y=height / filledoutlinedmarkers
                                markerfillattrs    = (color     =  red)
                                markeroutlineattrs = (color     =  blue
                                                      thickness =  2)
                                markerattrs        = (size      =  30
                                                      symbol    =  DiamondFilled);

    keylegend / position=right type=marker;                                                    
    keylegend / position=right type=markercolor  scale=;                                                    
    keylegend / position=right type=markersymbol;                                                    
run;
5 REPLIES 5
Ksharp
Super User

Why not create some DUMMY scatter variable to mock this ?

 

proc sgplot data=sashelp.class;
    scatter x=weight y=height /  name='a'
                                markerattrs        = (size      =  10 color=grey
                                                      symbol    =  DiamondFilled);
    scatter x=weight y=height /  name='b'
                                markerattrs        = (size      =  20 color=grey
                                                      symbol    =  DiamondFilled);
    scatter x=weight y=height /  name='c'
                                markerattrs        = (size      =  30 color=grey
                                                      symbol    =  DiamondFilled);


    scatter x=weight y=height / filledoutlinedmarkers name='d'
                                markerfillattrs    = (color     =  red)
                                markeroutlineattrs = (color     =  blue
                                                      thickness =  2)
                                markerattrs        = (size      =  30
                                                      symbol    =  DiamondFilled);

    keylegend 'a' 'b' 'c'/across=1 position=right type=marker;                                                    
run;

Ksharp_0-1726365723821.png

 

 

xxformat_com
Barite | Level 11

As for multiple legenditem, it overloads the procedure when we could expect the size given in the wall to be reused. fill type have its options. I would expect something similar to be available for symbols.

 

ballardw
Super User

@xxformat_com wrote:

As for multiple legenditem, it overloads the procedure when we could expect the size given in the wall to be reused. fill type have its options. I would expect something similar to be available for symbols.

 


What do you mean by "overloads the procedure"?

Really, to get workable graphs you should provide some example data that behaves like your data and your code. Your example code using SASHELP.CLASS only ever generates one symbol so I am having a very hard time understanding what you intend.

 

If you provide a NAME= option for plots and create multiple plots with different names then the KEYLEGEND can reference a subset of the plots. So what you might be intending might be possible with overlayed plots with differences but without a concrete example it is very hard to dummy up something similar.

 

xxformat_com
Barite | Level 11

The swimmer plot is an example where type= option could be used in keylegend.

 

In this paper you can start to see that the code starts to get messy with so many scatter statement.

https://www.lexjansen.com/phuse-us/2018/dv/DV08.pdf

Here we have to keep in mind that programs have to be validated in clinical research and programmers don't really like validating other people programs. 

So it is essentiel to have short effective and comprehensive code to facilitate the process.

 

The SAS system offers the opportunity to derive items from a specific symbol plotted on the graph. If we don't have any flexibility to define the symbol size, then the benefit of the feature is lost and we keep with old workaround.

ballardw
Super User

@xxformat_com wrote:

The swimmer plot is an example where type= option could be used in keylegend.

 

In this paper you can start to see that the code starts to get messy with so many scatter statement.

https://www.lexjansen.com/phuse-us/2018/dv/DV08.pdf

Here we have to keep in mind that programs have to be validated in clinical research and programmers don't really like validating other people programs. 

So it is essentiel to have short effective and comprehensive code to facilitate the process.

 

The SAS system offers the opportunity to derive items from a specific symbol plotted on the graph. If we don't have any flexibility to define the symbol size, then the benefit of the feature is lost and we keep with old workaround.


What process? I am still not sure what you even want.

 

 

Sometimes "messy" plot code comes because the programmer doesn't want to restructure the DATA.

Sometimes the code is messy because someone is making a very complicated graph.

Sometimes the code in a white paper is to show the possibilities and not always the best way to accomplish one specific task.

 

So, can to start over and describe what the graph you are concerned with, not the ones in the paper, but your graph is supposed to show?

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 5 replies
  • 988 views
  • 0 likes
  • 3 in conversation