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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.