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;
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;
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;
Thanks so much @Ksharp !!!
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)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.