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.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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