Data visualization with SAS programming

proc sgplot changing the histogram pattern

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 118
Accepted Solution

proc sgplot changing the histogram pattern


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.


Accepted Solutions
Solution
‎12-03-2013 09:27 AM
SAS Super FREQ
Posts: 1,078

Re: proc sgplot changing the histogram pattern

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


All Replies
Occasional Contributor
Posts: 15

Re: proc sgplot changing the histogram pattern

Frequent Contributor
Posts: 118

Re: proc sgplot changing the histogram pattern

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;

SAS Employee
Posts: 244

Re: proc sgplot changing the histogram pattern

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

-Jeff

Super Contributor
Posts: 273

Re: proc sgplot changing the histogram pattern

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;

Frequent Contributor
Posts: 118

Re: proc sgplot changing the histogram pattern

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;

Solution
‎12-03-2013 09:27 AM
SAS Super FREQ
Posts: 1,078

Re: proc sgplot changing the histogram pattern

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.

New Contributor Cx
New Contributor
Posts: 3

Re: proc sgplot changing the histogram pattern

How do you specify a fill pattern for 9.4 histogram?

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 1981 views
  • 0 likes
  • 6 in conversation