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

I'd like to create a Plot 1 without the empty space with no information. Ideally, I want to show xaxis only for the range of 0.004-0.006 keeping CI95% brackets as narrow as shown in plot1. However, every time I use min, max, offsetmin, offsetmax options or values=from to by, or xaxis min=0.004 options in the code, 95%CI brackets become so wide as shown in Plot 2 which is not desirable. Please help how to create Plot 1 but without the empty space in front.

 

Plot 1. Desirable dimension and style of plot for narrow CI95%. But I would like to eliminate the space without information until from 0 to 0.004

CI95.png

 

Plot 2. Undesirable style but resulted from code with xaxis min=0.004

undesired.png

 

 

k

proc sgplot data=data;
   scatter y=Risk x=Rate/ xerrorlower=LowerCL xerrorupper=UpperCL
           markerattrs=(symbol=diamondfilled)
           group=Type groupdisplay=cluster;
   xaxis grid min=0;
   yaxis grid colorbands=odd discreteorder=data type=discrete;
   label Rate = "Rate";
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

The CI bar widths are scaled to the x-axis based on the values you provide in the LowerCL and UpperCL variables in the data set.  It is the same in both the graphs.  Plot 1 has bigger range on the x-axis, so the same bar widths look smaller.  The only way to change them is if you change the values in the LowerCL and UpperCL variables in the data set.

View solution in original post

5 REPLIES 5
Jay54
Meteorite | Level 14

Don't set the min=0 on the xaxis statement.  Then you will not get the empty space. 

The CI bar widths depend on the values in the data you are providing and scaled with the x-axis.

Cruise
Ammonite | Level 13

@Jay54

Thanks Sanjay. Commenting out min=0 resulted in widened 95CI. Desirable plot is narrow and tall CI95 as shown in plot 1.

 

proc sgplot data=p.alb_conc;
   scatter y=Risk x=Rate/ xerrorlower=LowerCL xerrorupper=UpperCL
           markerattrs=(symbol=diamondfilled)
           group=Type groupdisplay=cluster;
/*   xaxis grid min=0.004;*/
   yaxis grid colorbands=odd discreteorder=data type=discrete;
   label Rate = "Rate";
   title 'hi';
run;
Jay54
Meteorite | Level 14

The CI bar widths are scaled to the x-axis based on the values you provide in the LowerCL and UpperCL variables in the data set.  It is the same in both the graphs.  Plot 1 has bigger range on the x-axis, so the same bar widths look smaller.  The only way to change them is if you change the values in the LowerCL and UpperCL variables in the data set.

Cruise
Ammonite | Level 13
Sanjay, I'm using noautolegend, do you know how to label for each type=discrete in legend on the side of the plot? any reference document for the similar plot?
Jay54
Meteorite | Level 14

If you leave out the NOAUTOLEGEND you will get the default legend at the bottom.  You can customize its position by using a KEYLEGEND / position=right across=1;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1478 views
  • 2 likes
  • 2 in conversation