Data visualization with SAS programming

SGPLOT graph patterns

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 105
Accepted Solution

SGPLOT graph patterns

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;  

Accepted Solutions
Solution
‎10-26-2017 01:06 PM
SAS Super FREQ
Posts: 375

Re: SGPLOT graph patterns

Posted in reply to jacksonan123

All Replies
Solution
‎10-26-2017 01:06 PM
SAS Super FREQ
Posts: 375

Re: SGPLOT graph patterns

Posted in reply to jacksonan123
SAS Super FREQ
Posts: 945

Re: SGPLOT graph patterns

[ Edited ]
Posted in reply to jacksonan123

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;
 

 

Frequent Contributor
Posts: 105

Re: SGPLOT graph patterns

This option also works well.
Super User
Posts: 20,224

Re: SGPLOT graph patterns

Posted in reply to jacksonan123

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...

Frequent Contributor
Posts: 105

Re: SGPLOT graph patterns

This is also an approach that works.
☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 95 views
  • 0 likes
  • 4 in conversation