BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10


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.

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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.

View solution in original post

7 REPLIES 7
sasphd
Lapis Lazuli | Level 10

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;

JeffPerkinson_JMP
SAS Employee

I've moved this thread from the JMP Discussion Forum to the SAS/GRAPH and ODS Graphics community.

-Jeff

Andre
Obsidian | Level 7

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;

sasphd
Lapis Lazuli | Level 10

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;

Jay54
Meteorite | Level 14

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.

Cx
Calcite | Level 5 Cx
Calcite | Level 5

How do you specify a fill pattern for 9.4 histogram?

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
  • 7 replies
  • 7152 views
  • 0 likes
  • 6 in conversation