- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I want both graphs to have the same color for the class variable. For the histogram, the coloring is set by
styleattrs DATACOLORS=(blue red )
But how do I set the same colors to differentiate between the classes in the vbar?
%let _input = sashelp.bweight;
%let class=black;
%let response=weight ;
proc sgplot data=&_input.;
title "Distribution &response.";
styleattrs DATACOLORS=(blue red );
histogram &response. / group=&class. transparency=0.5;
density &response. / group=&class. lineattrs=(pattern=solid);
xaxis display=(nolabel);
run;
proc sgplot data=&_input.;
styleattrs DATACOLORS=(blue red ) ;
title "Mean &response. per &class. ";
vbar &class. / response=&response. stat=Mean name='Bar' filltype= solid datalabel;
yaxis grid;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Add the GROUP= Option to the VBAR Options to make the procedure alter between the specified datacolors
%let _input = sashelp.bweight;
%let class=black;
%let response=weight ;
proc sgplot data=&_input.;
title "Distribution &response.";
styleattrs DATACOLORS=(blue red);
histogram &response. / group=&class. transparency=0.5;
density &response. / group=&class. lineattrs=(pattern=solid);
xaxis display=(nolabel);
run;
proc sgplot data=&_input.;
styleattrs datacolors=(blue red) ;
title "Mean &response. per &class. ";
vbar &class. / group=&class. response=&response. stat=Mean name='Bar' filltype=solid datalabel;
yaxis grid;
run;
Edit: Also, you can add the transparency=0.5 to the VBAR option (as in the histogram options) to make the colors exactly the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Add the GROUP= Option to the VBAR Options to make the procedure alter between the specified datacolors
%let _input = sashelp.bweight;
%let class=black;
%let response=weight ;
proc sgplot data=&_input.;
title "Distribution &response.";
styleattrs DATACOLORS=(blue red);
histogram &response. / group=&class. transparency=0.5;
density &response. / group=&class. lineattrs=(pattern=solid);
xaxis display=(nolabel);
run;
proc sgplot data=&_input.;
styleattrs datacolors=(blue red) ;
title "Mean &response. per &class. ";
vbar &class. / group=&class. response=&response. stat=Mean name='Bar' filltype=solid datalabel;
yaxis grid;
run;
Edit: Also, you can add the transparency=0.5 to the VBAR option (as in the histogram options) to make the colors exactly the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, didnt realise I needed to specify groups= , thought that would be implicit.