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

Hi there,

 

I'm looking for a way to tune this PROC SGPLOT produced graph. I don't mind changing to a different procedure while the result remains the same. 

 

  1. Firstly, and more importantly, I would like to find a way to change the color of a custom background area of the plot in order to highlight a certain boxplot from a group of boxplots (see the attached figure).
  2. Secondly, I haven't found a way to control the x axis width when there is no scale on it (as in my boxplot example) because in that case the "xaxis min=0 max=6" statement doesn't make sense (I have shown also in the attached figure what I would like to achieve)

Thanks in advance for all your help and comments!!

 

sas-boxplot.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

It is hard to say what your x-axis range is as you have turned the axis off.  If the axis is numeric 1-6, then you could set the values=(1 to 4 by 1).  Or, you can reduce the min and max offsets.

 

For the highlighting, place a "X" reference line behind the box plot with x value ='Global', and increase the line thickness.  Use transparency and color you want.

 

proc sgplot data=sashelp.heart;
  refline 'Coronary Heart Disease' / axis=x 
          lineattrs=(thickness=70 color=yellow) transparency=0.5 ;
  vbox cholesterol / category=deathcause;
run;

 

BoxHighlight.png 

View solution in original post

3 REPLIES 3
Jay54
Meteorite | Level 14

It is hard to say what your x-axis range is as you have turned the axis off.  If the axis is numeric 1-6, then you could set the values=(1 to 4 by 1).  Or, you can reduce the min and max offsets.

 

For the highlighting, place a "X" reference line behind the box plot with x value ='Global', and increase the line thickness.  Use transparency and color you want.

 

proc sgplot data=sashelp.heart;
  refline 'Coronary Heart Disease' / axis=x 
          lineattrs=(thickness=70 color=yellow) transparency=0.5 ;
  vbox cholesterol / category=deathcause;
run;

 

BoxHighlight.png 

emera86
Quartz | Level 8

Thanks a lot @Jay54 for your help!!

 

The offset attribute wasn't working for me because it just moves the the plot towards one side or another, but you gave me a clue on where to search for a proper solution. I finally solved it changing the THRESHOLDMIN and THRESHOLDMAX values, which control the spacing between the left and right border of the plot respectively.

 

About the line reference, it totally solved my problem in a very simple way. Thanks for such an ingenious solution!!

 

Thanks again!!

Jay54
Meteorite | Level 14

You are welcome.  For future reference, it is easier to help if you attach your code and some sample data.  Then we can see what you are getting and how to help.  Version of SAS also helps.

 

The RefLine thickness will impact the offsets.  You can set the offsetmin and offsetmax to control the white space.

 

BoxHighlight.png

proc sgplot data=sashelp.heart;
  refline 'Coronary Heart Disease' / axis=x 
          lineattrs=(thickness=70 color=yellow) transparency=0.5 ;
  vbox cholesterol / category=deathcause;
  yaxis offsetmin=0.05 offsetmax=0.05;
run;

 

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
  • 3 replies
  • 1058 views
  • 1 like
  • 2 in conversation