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

Coloring the xaxistable values using colorgroup and styleattrs.

 

First scenario, there is one color per group as specified in the styleattrs.

 

proc sql;
    create table class as
        select put(age,best.-l) as age
             , case when age in (12,13) then '12-13'
                    when age in (14,15) then '14-15' 
                    else 'Other'
               end as agegrp
             , mean(height) as mean_height
        from sashelp.class
        group by age;
quit;

proc print data=class noobs;
run;

proc sgplot data=class;
    vbarbasic age / response=mean_height;
    xaxistable mean_height / colorgroup = agegrp;
    styleattrs datacontrastcolors=(black green red);
run;

Second scenario, only the non missing groups take a color given in styleattrs.

proc sql;
    create table class as
        select put(age,best.-l) as age
             , case when age in (12,13) then '12-13'
                    when age in (14,15) then '14-15' 
                    else ' ' /*different from scenario 1*/
               end as agegrp
             , mean(height) as mean_height
        from sashelp.class
        group by age;
quit;

proc sgplot data=class;
    vbarbasic age / response=mean_height;
    xaxistable mean_height / colorgroup = agegrp;
    styleattrs datacontrastcolors=(/*black*/ green red);
run;

Is there an option to control the color of xaxisvlues for the missing value of the variable given in colorgroup while using styleattrs?

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

By default, the missing color is special, and it is retrieved from the active ODS style. However, if you use an attributes map instead of STYLEATTRS, you can control all of the colors, including "missing".

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

By default, the missing color is special, and it is retrieved from the active ODS style. However, if you use an attributes map instead of STYLEATTRS, you can control all of the colors, including "missing".

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