BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

Hi,

I'm wondering when the name= option of the xaxistable/yaxistable could be used.

 

I've created an example where name='test' is not referenced anywhere.

 

proc sql;
    create table class as
    select sex, mean(height) as mean_height
    from sashelp.class
    group by sex;
run;

proc sgplot data=class ;
    vbarbasic sex / response=mean_height;
    xaxistable mean_height / name='test';
    legenditem type=text name='A' / text='xx'
                                    label='Demo';
    keylegend 'A' / position=right;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@xxformat_com wrote:
When I added 'text' in keylegend nothing was displayed. Therefore I was wondering if it was recognized and what text would then be displayed in the legend.

Legends would not be created in a graph with with a single Plot statement (i.e. Vbarbasic) with no overlay or group variable. XAXISTABLE by itself doesn't create a legend as it is not a plot statement.

 

Contrived and not a suggested graph but demonstrates name= with multiple XAXISTABLE statements:

proc sgplot data=sashelp.class ;
    vbar sex / response=height stat=mean group=age name='bar';
    xaxistable height / colorgroup=age  name='test';
    xaxistable weight / colorgroup=sex  name='test2';
    keylegend  'test' / position=bottom title='Mean Height';
    keylegend  'test2'/ position=right title='Weights';
run;

Note the different colorgroup variable, what that does to the row variables.

Default behavior is going to reuse colors which is why this isn't a very good graph but you were asking about Name= and shows that you can get different somewhat different legends for different XAXISTABLEs.

 

View solution in original post

3 REPLIES 3
ballardw
Super User

Pretty much the same reasons as having the Name= option for any of the plots: control of keylegend output.

Remember that you can have multiple XAXISTABLE statements in a single plot. If you want to create a Keylegend output you have to be able to tell keylegend which one to use.

Also, you may want to use multiple Keylegend statements to create multiple legends and again need names to control which legend options go with which item.

xxformat_com
Barite | Level 11
When I added 'text' in keylegend nothing was displayed. Therefore I was wondering if it was recognized and what text would then be displayed in the legend.
ballardw
Super User

@xxformat_com wrote:
When I added 'text' in keylegend nothing was displayed. Therefore I was wondering if it was recognized and what text would then be displayed in the legend.

Legends would not be created in a graph with with a single Plot statement (i.e. Vbarbasic) with no overlay or group variable. XAXISTABLE by itself doesn't create a legend as it is not a plot statement.

 

Contrived and not a suggested graph but demonstrates name= with multiple XAXISTABLE statements:

proc sgplot data=sashelp.class ;
    vbar sex / response=height stat=mean group=age name='bar';
    xaxistable height / colorgroup=age  name='test';
    xaxistable weight / colorgroup=sex  name='test2';
    keylegend  'test' / position=bottom title='Mean Height';
    keylegend  'test2'/ position=right title='Weights';
run;

Note the different colorgroup variable, what that does to the row variables.

Default behavior is going to reuse colors which is why this isn't a very good graph but you were asking about Name= and shows that you can get different somewhat different legends for different XAXISTABLEs.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 438 views
  • 1 like
  • 2 in conversation