Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
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-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
  • 501 views
  • 1 like
  • 2 in conversation