Hi,
I know it's stupid question but want to check its possible? Can we create a box plot in proc template without using the 'Boxplot' statement. The reason for this alot of customization involved in my requirement, where box plot statement is restricting me to change because of no options available. Is it possible to create the Exact box plot using the 'Bar' and Scatterplot Statements? ( I feel like dumb while writing the requirement, unfortunately I don't have the choice)
Thank you for your opinions.
data dummy_data;
call streaminit(123);
do id = 1 to 10;
group = 'A';
value = rand('Uniform') * 30 + 20;
output;
group = 'B';
value = rand('Uniform') * 30 + 30;
output;
end;
run;
proc print data=dummy_data;
run;
data dummy_data;
call streaminit(123); /* Set seed for reproducibility */
do id = 1 to 10;
group = 'A';
value = rand('Normal', 50, 10); /* Mean=50, SD=10 */
output;
group = 'B';
value = rand('Normal', 65, 12); /* Mean=65, SD=12 */
output;
end;
run;
proc template;
define statgraph myboxplot;
begingraph;
entrytitle "Comparison of Values by Group";
layout overlay /
xaxisopts=(label="Group" discreteopts=(tickvaluefitpolicy=rotatethin))
yaxisopts=(label="Measurement Value");
boxplot x=group y=value /
group=group
boxwidth=0.5
capshape=line
meanattrs=(symbol=circlefilled color=black size=8)
medianattrs=(color=red)
whiskerattrs=(pattern=solid)
outlierattrs=(color=blue symbol=circlefilled);
referenceline y=55 / lineattrs=(color=gray pattern=dash);
discretelegend "boxplot" / title="Group";
endlayout;
endgraph;
end;
run;
proc sgrender data=dummy_data template=myboxplot;
run;
We have a BOXPLOTPARM statement, which will give you maximum control of the DATA passed into the box plot rendering. If you are wanting to have maximum control GRAPHICALLY to build box plots, consider using the following statements (specified in this order in the Layout Overlay):
I'm not sure of your exact requirements, but hopefully this will get you started.
Thank you @DanH_sas . Can you please direct me to any references? if you can
Perfect. Thank you @Ksharp
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.
Ready to level-up your skills? Choose your own adventure.