BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aline1610
Fluorite | Level 6

Hello, 

i need to display a boxplot of a quantitative variable (diox_q3) according to a binary variable (statut_kt) so i used this code :

PROC SGPLOT DATA= NHL; vbox diox_q3/category=statut_kt;run; 

but the boxplot is not readable ; the scale of the y axis is not appropriate since my quantitative variable has very low values :

median=5.20*10^-8

Q1(25%)= 4.026*10^-9

Q3(75%)=3.12*10^-7

How can i change the scale of the y axis to get a relevant boxplot ?

Thank you in advance for your help ! 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

First, you really should say what is "wrong" with the graph, or better post it.

Second better is to provide actual data.

 

Below are a couple of data steps that create what I an guessing is your problem, a few values that are relatively much large larger than the values that would comprise the box part of the plot and a default plot. Then follow two approaches to controlling the Yaxis to display some box.

Data and default plot:

data plot2;
   do i=1 to 100;
      x=rand('normal',5.0e-8,1.0e-8);
      output;
   end;
   /*add a few larger values*/
   do i=101 to 110;
      x=rand('normal',3.0e-4,1.0e-4);
      output;
   end;
run;

PROC SGPLOT DATA= plot2; 
   vbox x;
run; 

And two different plots:

/* force yaxis to show smaller range trims outliers*/

PROC SGPLOT DATA= plot2; 
   vbox x/;
   yaxis values=(1.0e-8 to 1.0e-7 by 5.0e-9);
run; 

/* use log axis*/
PROC SGPLOT DATA= plot2; 
   vbox x/;
   yaxis type=log logbase=10 logstyle=linear;
run; 

The actual range of values and increment in the VALUES= option likely need tweaking for your data.

It may also help to increase the size of your graph display area with an ODS Graphics option statement.

View solution in original post

2 REPLIES 2
ballardw
Super User

First, you really should say what is "wrong" with the graph, or better post it.

Second better is to provide actual data.

 

Below are a couple of data steps that create what I an guessing is your problem, a few values that are relatively much large larger than the values that would comprise the box part of the plot and a default plot. Then follow two approaches to controlling the Yaxis to display some box.

Data and default plot:

data plot2;
   do i=1 to 100;
      x=rand('normal',5.0e-8,1.0e-8);
      output;
   end;
   /*add a few larger values*/
   do i=101 to 110;
      x=rand('normal',3.0e-4,1.0e-4);
      output;
   end;
run;

PROC SGPLOT DATA= plot2; 
   vbox x;
run; 

And two different plots:

/* force yaxis to show smaller range trims outliers*/

PROC SGPLOT DATA= plot2; 
   vbox x/;
   yaxis values=(1.0e-8 to 1.0e-7 by 5.0e-9);
run; 

/* use log axis*/
PROC SGPLOT DATA= plot2; 
   vbox x/;
   yaxis type=log logbase=10 logstyle=linear;
run; 

The actual range of values and increment in the VALUES= option likely need tweaking for your data.

It may also help to increase the size of your graph display area with an ODS Graphics option statement.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 3112 views
  • 0 likes
  • 3 in conversation