How to compare distribution of variables using Box Plot in SAS?

visualization
sas
box_plot

#1

Hi,

In my data set, there is various variables like Var1, Var2, Var3, Var4, Var5 and all are numeric. I want to compare distribution of all these variables using Box plot on the same plot. Can you please help me to plot this using SAS.

Data set:

ID       Var1       Var2       Var3       Var4       Var5
A001    23           35          32          38           26
A002    18           28          45          67           34 
A003    36           19          47          38           56 
A004    54           36          29          38           57
A005    19            7           19          17           18  
A006    37           78          38          57           67 
A007     6            34          28          18           23
A008    32           23          24          34           23
A009    18           24          29          19           18
A010    19           35          45          37            45

Regards,
Steve


#2

@Steve
It can be done in two steps.
Step:-1 Transpose the data set where variable name would be the category as a new variable and respective values against each variable name and ID.

Data Set:

Data Test;
Input ID$ Var1 Var2 Var3 Var4 Var5;
datalines;
A001    23           35          32          38           26
A002    18           28          45          67           34 
A003    36           19          47          38           56 
A004    54           36          29          38           57
A005    19            7           19          17           18  
A006    37           78          38          57           67 
A007     6            34          28          18           23
A008    32           23          24          34           23
A009    18           24          29          19           18
A010    19           35          45          37            45
;
Run;

Transposing data set

Proc transpose data=test out=trans_test name=Var_Name;
          by ID;
  Run;

Step:-2 Draw Box plot using Proc SGPLOT, where category is variable name and values against each category and ID is under variable Col1.

Proc sgplot data=trans_test;
  vbox Col1 / category=Var_Name;
run;

Regards,
Sunil