I am comparing median laboratory values and mortality. I have 10 different labs on about 400 patients. I have created a box and whisker plot for each lab individually and mortality - see simple example code below. I would like them to all be included in one panel such as with sgpanel but since they are separate variables, I haven't been able to figure it out. They would each require their own Y axis since they have different scales.
I would also love help with labeling mortality (outcome, 0 = deceased, 1 = survived) on the x-axis.
proc sgplot data=eb;
title 'AST overall value by survival';
vbox AST / category=outcome;
run;
data test;
array temp (*) _NUMERIC_ val1-val10;
do client=1 to 400;
do j=1 to dim(temp);
temp(j)=ceil(rand('integer',1,10) + rand("normal", mod(client, 5), rand('bernoulli', rand('integer',1,10)/10))) ;
end;
client_id=cats("id_", client);
outcome= rand('bernoulli', mod(client, 3)/2);
output;
end;
drop client j;
run;
proc format;
value outy
0='deceased'
1='survived'
;
run;
ods graphics on;
proc sgplot data=test;
format outcome outy.;
title 'AST overall value by survival';
vbox val1 / category=outcome;
run;
proc transpose data=test out=long(rename=(col1=value));
by client_id outcome notsorted;
var val1-val10;
run;
proc sgpanel data=long;
panelby _name_;
format outcome outy.;
vbox value / category=outcome;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.