BookmarkSubscribeRSS Feed
cd2011
Calcite | Level 5

Hi Guys,

 

So I have this question for you. I have a stacked bargraph that I produced using SGPLOT, where I created textured fill to distinguish between subgroups using patternid. But, I could not replicate that in SGPANEL, where bars are stacked by subgroup, and then there are different plots for differenet groups, thats why using sgpanel. 

 

I think I can do it using template, but is there an easier way ? Maybe, a optin like patternid in SGPLOT? My search did not yield any results. 

 

Thanks a bunch in advance !

3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
PATTERNID is for PROC GCHART. You use different methods with SGPLOT. Can you post the SGPLOT code or code showing SGPLOT and PATTERNID that worked?

cynthia
cd2011
Calcite | Level 5

You might be right. I dont have the code file with me so I cant check. But it could be gchart. I will check if it worked with SGPLOT and post an update. But definitely did not work with SGPANEL. 

Cynthia_sas
SAS Super FREQ

Hi:

  You cannot "mix" SAS/GRAPH controls or SAS/GRAPH procedures with ODS GRAPHICS controls and ODS GRAPHICS procedures. So PROC GCHART will not work with SGPANEL.

 

  However, a modification of this Tech Support example, http://support.sas.com/kb/45/663.html worked for me with SGPLOT and SGPANEL.

cynthia

 

*** the code;

 

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
  
proc template;
   define style mypatterns;
   parent=styles.rtf;

   /* The GraphBar element must be included with the
      FILLPATTERN option in order to use fill patterns. */
   style GraphBar from GraphComponent /                                 
         displayopts = "outline 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;

options nodate number;
ods pdf file='c:\temp\pat_sg_pan_ex1a.pdf' style=mypatterns;
ods html gpath='c:\temp' (url=none)
         path='c:\temp' (url=none) 
         file='pat_sg_pan_ex1b.html' style=mypatterns;
ods rtf file='c:\temp\pat_sg_pan_ex1c.rtf' style=mypatterns;

title 'Using fill patterns with a bar chart';

data sample;
   length grpvar $8;
   input mid $ value;
   do supergroup = 'Z1', 'Z2';
     do grpvar='One', 'Two', 'Three';
       if grpvar = 'One' then output;
	   else if grpvar = 'Two' then do;
	      value = value + 3;
		  output;
	   end;
	   else do;
	     value = value + 5;
	     output;
	   end;
     end;
   end;
return;
datalines;
A 10
B 20
C 25
;
run;

** plot one "supergroup";
proc sgplot data=sample noautolegend;
   where supergroup = 'Z1';
   vbar mid / response=value stat=mean group=grpvar groupdisplay=cluster 
              grouporder=data name="Bar";
xaxis label="Grouped";
yaxis label="Mean" values=(0 to 35 by 5);
keylegend "Bar" / title="Wombat" ;
run;

** plot both "supergroups" with SGPANEL;
proc sgpanel data=sample;
   panelby supergroup;
   vbar mid / response=value stat=mean group=grpvar groupdisplay=cluster 
              grouporder=data name="Bar2";
colaxis label="Grouped";
rowaxis label="Mean" values=(0 to 50 by 5);
run;
ods _all_ close;

 

*** the output;

sgplot_sgpanel_pattern.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1764 views
  • 0 likes
  • 2 in conversation