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

I have the following code which works.  Can someone tell me how to modify the code so that the graph will have patterns instead of color?  

ods pdf file='/folders/myfolders/Cmax_con/peaksdistr.pdf/';  
 ods graphics on /width=4 in; 
 title 'Cmax distribution Peak1';
 proc sgplot data=peak1;
  histogram  y/ legendlabel='Calculated Cmax' fillattrs=(color=red) name= 's' legendlabel ='Calculated Cmax' transparency=0.5 ;
   histogram  dv/ legendlabel='Calculated Cmax' fillattrs=(color=green) name= 'o' legendlabel ='Observed Cmax' transparency=0.5 ;
  keylegend 's' 'o'  /location=inside position =topright across=1; 
  xaxis label='ng/ml'; 
  
 run;
  ods pdf close;  
1 ACCEPTED SOLUTION
5 REPLIES 5
DanH_sas
SAS Super FREQ

For v940m5, it is as simple as specifying FILLPATTERN and NOFILL on both HISTOGRAM statements. However, for prior versions, you will need to make an ODS style change to get the patterns. Something like the following:

 

proc template;
define style styles.mypat;
  parent=styles.HTMLBlue;
  style Graphhistogram from GraphComponent /
      displayopts = "outline fillpattern"
  ;
end;
run;

ods html style=styles.mypat;
proc sgplot data=sashelp.class;
  histogram weight;
  histogram height;
run;
 

 

jacksonan123
Lapis Lazuli | Level 10
This option also works well.
Reeza
Super User

FILLPATTERN is an option on the Histogram statement if you want manual control of the patterns.

 

http://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n17xrpcduau1f8n1c1nhe477pv18.htm&docs...

jacksonan123
Lapis Lazuli | Level 10
This is also an approach that works.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1420 views
  • 0 likes
  • 4 in conversation