Dear all,
I am new to SAS (coming from R) and i would like to sort boxplot by the median of the variable being plotted.
The code i have generated using SAS Enterprise is the following:
Is there a way to modify such code in order to get the desired order of the boxplots?
Thanks for any help!
Rick'blog have such an example .
http://blogs.sas.com/content/iml/2014/09/10/viz-distributions-of-100-vars.html
Give you an example. If you have SAS9.4 ,that would be more easy by using SQL.
data class;
set sashelp.heart;
array x{*} _numeric_;
do i=1 to dim(x);
vname=vname(x{i});
value=x{i};
output;
end;
keep vname value;
run;
proc sort data=class;by vname;run;
proc summary data=class;
by vname;
var value;
output out=median(drop=_:) median=median;
run;
data want;
merge class median;
by vname;
run;
proc sort data=want;by median;run;
proc sgplot data=want ;
vbox value/category=vname;
xaxis discreteorder=data;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.