BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

Is there a way to specify each bar (PARAMN) be a different pattern and each BY value (ARMN) be a different color? I would like PARAMN in (1 2) to be a different pattern from the others since they're the controls. And I'd like each treatment group to be consistent throughout my report (some figures will have all treatment groups displayed in one figure).

PROC TEMPLATE specifications seem to only affect GROUP variables and not CATEGORY variables.

data Dummy;
   	do USUBJID = 1 to 9;
   	do ARMN= 1 to 5;
   	do ATPTN= 1, 8, 29, 36, 57, 64, 85, 181;
 	do PARAMN = 1 to 5; output; end;
	output;
   	end; end; end;
run;

/*Formats*/
proc format;
 value armn
 	1 = 'Group A' 
	2 = 'Group B'
	3 = 'Group C'
	4 = 'Group D'
	5 = 'Group E'
	;
 value paramn
 	1	= 'Medium Only'
	2	= 'Normal Human Sera'
	3	= 'Experimental Sera'
	4	= 'HI Experimental Sera'
	5	= 'Exp. Sera + Exo. Comp.'
	;
run;

/*Test Data*/
data ADCC;
 set Dummy;
 call streaminit(57);
	NDS = rand("integer", 90, 125);		/*NDS=Number of Dead*/
   	TNS = rand("integer", 150, 250);	/*TNS=Total Number*/
 	PDS = 100*NDS/TNS;					/*PDS=Percentage of Dead*/
	LPDS= log(PDS);						/*LPDS=Log-Transformed PDS for GM calculations*/
run;

/*Geometric Mean (95% CI)*/
proc means data= ADCC noprint nway;
 class ARMN ATPTN PARAMN;				/*ARMN=Treatment Arm (N); ATPTN= Study Day (N); PARAMN=Test Type*/
 var LPDS;
 output out= _GM mean= AVG lclm= _LB uclm= _UB;
data GM;
 set _GM;
 	GM = exp(AVG);
	LB = exp(_LB);
	UB = exp(_UB);
 keep ARMN ATPTN PARAMN GM--GMCI;
proc sort data= GM; by ARMN ATPTN PARAMN; 
run;

/*Bar Plot*/
proc template;
 define style adcc_fig;
 parent= styles.default;
 	style GraphBar from GraphComponent 	/ displayopts= "outline fillpattern";
	style GraphData1 from GraphData1	/ fillpattern= "S";
	style GraphData2 from GraphData2	/ fillpattern= "S";
	style GraphData3 from GraphData3	/ fillpattern= "X2";
	style GraphData4 from GraphData4	/ fillpattern= "X3";
	style GraphData5 from GraphData5	/ fillpattern= "X4";
 end;
run;

options nobyline;
ods word file= "&rptout./Fig_ADCC.docx" style= adcc_fig options(cant_split= 'on' body_title= 'on');
proc sgpanel data= GM;
 by ARMN;
 panelby ATPTN / novarname onepanel columns= 3;
 vbarparm category= PARAMN response= GM / limitlower= LB limitupper= UB /*group= ARMN groupdisplay= cluster grouporder= data*/;
 rowaxis min= 0 max= 100 label= "In Vitro Killing (%) Geometric Mean";
 colaxis label= "Sera Type";
 format PARAMN paramn. ARMN armn.;
run;
ods word close;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@mariko5797 wrote:
So I want BY variable (ARMN=treatment group) to be different colors, i.e., each individual graph has different colors outputted.

Not going to happen as a By variable option. This could be done with each graph having data selected with a WHERE statement and providing the different options whether as template or procedure styleattrs options.

Also sounds likely to cause more confusion than help clarify results.

 

Use your PARAMN variable as a Group variable as well as the Category. You would need to add Groupdisplay=cluster to allow the errorbars to appear. If different plots may not include all the values of PARAMN then a Dattrmap is the approach to get the bars to appear the same across plots. But that does bring up the current limit of Dattrmap doesn't support Fillpatterns and seems to override them when provided in a style template.

 

View solution in original post

3 REPLIES 3
ballardw
Super User

What do you want colored based on the By variable values? It isn't at all clear what might be desirable.

Which variable is "treatment group"?

 

A DATTRMAP data set using a group variable is the typical way to keep the same appearance across plots but currently the DATTRMAP doesn't appear to support Fillpattern options and doesn't play well with them.

 

Your dummy data creates an additional value of Paramn=6 that is not in your format or template definitions.

mariko5797
Pyrite | Level 9
So I want BY variable (ARMN=treatment group) to be different colors, i.e., each individual graph has different colors outputted. I want the CATEGORY variable (PARAMN=sera type) to be different patterns.
ballardw
Super User

@mariko5797 wrote:
So I want BY variable (ARMN=treatment group) to be different colors, i.e., each individual graph has different colors outputted.

Not going to happen as a By variable option. This could be done with each graph having data selected with a WHERE statement and providing the different options whether as template or procedure styleattrs options.

Also sounds likely to cause more confusion than help clarify results.

 

Use your PARAMN variable as a Group variable as well as the Category. You would need to add Groupdisplay=cluster to allow the errorbars to appear. If different plots may not include all the values of PARAMN then a Dattrmap is the approach to get the bars to appear the same across plots. But that does bring up the current limit of Dattrmap doesn't support Fillpatterns and seems to override them when provided in a style template.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 480 views
  • 0 likes
  • 2 in conversation