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 !
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.
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.