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

I would like to add a vertical color band between 2 reference lines.  A code is attached below.  Basically I would like the area between X=40 and X=50 to be shaded with some transparency.  I tried REFLINE but there doesn't seem to be an option to color the area between them.


proc sgplot data=sashelp.Heart;
   Scatter X=AgeAtstart Y=Cholesterol;
   refline 40 50 / axis=x lineattrs=(thickness=3 color=darkred pattern=dash)
                     label=("Borderline"  "High"); 
run;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

proc sgplot data= sashelp.Heart;
   band y=Cholesterol lower=40 upper=50/transparency=0.6;

   Scatter X=AgeAtstart Y=Cholesterol;
   refline 40 50 / axis=x lineattrs=(thickness=3 color=darkred pattern=dash)
                     label=("Borderline"  "High"); 
run;

Ksharp_0-1708494354282.png

 

View solution in original post

3 REPLIES 3
Ksharp
Super User

proc sgplot data= sashelp.Heart;
   band y=Cholesterol lower=40 upper=50/transparency=0.6;

   Scatter X=AgeAtstart Y=Cholesterol;
   refline 40 50 / axis=x lineattrs=(thickness=3 color=darkred pattern=dash)
                     label=("Borderline"  "High"); 
run;

Ksharp_0-1708494354282.png

 

PamG
Quartz | Level 8

Thanks so much @Ksharp !!!

Rick_SAS
SAS Super FREQ

As KSharp shows, use the BLOCK statement. In addition to the example he provides, see Highlight forecast regions in graphs - The DO Loop (sas.com)

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1798 views
  • 4 likes
  • 3 in conversation