Hello,
I am creating two histograms in the same plot using this program:
sgplot data=alphas;
histogram alpha / transparency=0.75 fillattrs=(color=red);
histogram alpha_etoile / transparency=0.75 fillattrs=(color=blue);
yaxis label="Percent";
xaxis label="Alpha (%)";
run;
To differenciate the two histograms I want to use hatched area not colors, can someone help me?
Thanks.
Bar Charts support fill patterns, but Histograms do not. Fill patterns for Histograms has been added at SAS 9.4.M1 to be released soon.
This is helpful:
Thanks for your response.
When I copy that in sas 9.3 the word "Style" appears in red color and the result is not like suggested, there is no hatched area.
I guess that SAS do not consider proc Template.
proc template;
define style mypatterns;
parent=styles.listing;
/* The GraphBar element must be included with the
FILLPATTERN option in order to use fill patterns. */
style GraphBar from GraphComponent /
displayopts = "fillpattern";
/* Fill patterns are defined using the FILLPATTERN
style element attribute.
COLOR is used for the bar fill colors
CONTRASTCOLOR is used for the line colors */
style GraphData1 from GraphData1 /
fillpattern = "L3"
color=cxDADAEB
contrastcolor=cx252525;
style GraphData2 from GraphData2 /
fillpattern = "R3"
color=cxBCBDDC
contrastcolor=cx636363;
style GraphData3 from GraphData3 /
fillpattern = "X5"
color=cx9E9AC8
contrastcolor=cxCCCCCC;
style GraphData4 from GraphData4 /
fillpattern = "L5"
color=cx756BB1
contrastcolor=cxBDBDBD;
style GraphData5 from GraphData5 /
fillpattern = "X2"
color=cx6A51A3
contrastcolor=grayaa;
end;
run;
ods listing style=mypatterns;
title 'Using fill patterns with a bar chart';
data sample;
input mid $ value;
datalines;
A 10
B 20
C 25
D 15
E 25
;
run;
proc sgplot data=sample noautolegend;
vbar mid / response=value group=mid groupdisplay=cluster
grouporder=data dataskin=crisp;
run;
I've moved this thread from the JMP Discussion Forum to the SAS/GRAPH and ODS Graphics community.
-Jeff
It works
but you were in mistake using a listing destination that have by definition no style outside ods graphics!
your template were gone in your sasuser template depot
Andre
ods html style=Mypatterns;
proc sgplot data=sample noautolegend;
vbar mid / response=value group=mid groupdisplay=cluster
grouporder=data dataskin=crisp;
run;
Thanks it works for the Vbar. But when I use it for histogram it does not work??
ods html style=Mypatterns;
procsgplot data=sample noautolegend
histogram value ;
run;
Bar Charts support fill patterns, but Histograms do not. Fill patterns for Histograms has been added at SAS 9.4.M1 to be released soon.
How do you specify a fill pattern for 9.4 histogram?
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.
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.
Ready to level-up your skills? Choose your own adventure.