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

In my VBAR chart I want to shade AGE=16 with a gray background.  I have that working (AGE2=16) but I'm not able to figure out how to get the other block, (AGE2=. everything else) to have white background.  I don't understand how to use ATTR parameters to get what I need.

 

 

data class;
   set sashelp.class;
   if age eq 16 then age2=age;
   else age2=.;
   run;
proc sort;
   by age sex;
   run;
proc print;
   run;
ods output sgplot=sglot;
proc sgplot data=class;
  styleattrs DATACOLORS=(Black Gray);
  vbarbasic age / nooutline
      group = sex
      groupdisplay=cluster
      response=Weight
      stat=mean
      ;
  block x=age block=age2 / novalues transparency=.9; 
  run;

In the figure I have AGE=16 shaded as I would like.  I need to understand how get BLOCK AGE2=. not shaded or shaded with color=white.

 

 

Capture2.PNGCapture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Something like this should work for you:

proc sgplot data=class;
  styleattrs DATACOLORS=(Black Gray);
  vbarbasic age / nooutline
      group = sex
      groupdisplay=cluster
      response=Weight
      stat=mean
      ;
  block x=age block=age2 / novalues fillattrs=(color=white) 
      altfillattrs=(color=cxAAAAAA) transparency=0.9 filltype=alternate;
run;

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

Something like this should work for you:

proc sgplot data=class;
  styleattrs DATACOLORS=(Black Gray);
  vbarbasic age / nooutline
      group = sex
      groupdisplay=cluster
      response=Weight
      stat=mean
      ;
  block x=age block=age2 / novalues fillattrs=(color=white) 
      altfillattrs=(color=cxAAAAAA) transparency=0.9 filltype=alternate;
run;
data_null__
Jade | Level 19

Thanks @DanH_sas I will try this.  I found another way using X=AGE2 BLOCK=AGE2

  block x=age2 block=age2 / 
      FILLATTRS=(color='GRAY')
   novalues transparency=.8;

 

DanH_sas
SAS Super FREQ

Actually, your way is better, as "age2" contains only the one bar you want to highlight. That way, you don't have to deal with any interactions with the other bars.

ballardw
Super User

I am not sure what you want for output. Can you point to an example somewhat like what you want?

I suspect part of the issues may be the MISSING values for age2.

 

See if this with light green/ red backgrounds looks somewhat like you expect. If the "green" should be white then change it.

I'm not really sure what color you want for the age 16, but I would specify that instead where I have red.

You might also want the BLOCK before the VBARBASIC to avoid shading the bar colors.

data class;
   set sashelp.class;
   if age eq 16 then age2='block2';
   else age2='block1';
   run;
proc sort;
   by age sex;
   run;
proc print;
   run;
ods output sgplot=sglot;
proc sgplot data=class;
  styleattrs DATACOLORS=(Black Gray);
  block x=age block=age2 / filltype=alternate fillattrs=(color=green) altfillattrs=(color=red) novalues transparency=.9; 

  vbarbasic age / nooutline
      group = sex
      groupdisplay=cluster
      response=Weight
      stat=mean
      ;  

run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 285 views
  • 0 likes
  • 3 in conversation