BookmarkSubscribeRSS Feed
Recep
Quartz | Level 8

Hello all,

 

I'm trying to put reference lines into a figure that I would like to produce. The sample data and code below produces two reference lines through the complete x-axis (i.e. starting at y=0 for both reference lines for each block) whereas I want to have one reference line for the "Level1" block that starts at y=0 and ends at the end of the block, and another refence line that starts where the "Level 2" block starts (instead of starting at y=0). Is there any way to accomplish this within the PROC SGPLOT? I know that I can accomplish it if I was using PROC SGPANEL but that procedure creates other issues for me hence I want to stick to PROC SGPLOT.

 

Thanks a lot in advance!

 

 

 

data test;
input site $ city $ level $ obsmean cpred_final clower_final cupper_final;
datalines;
AB01 AB Level1 11.2716763 11.36606424 10.1001246 12.77349086
AB02 AB Level1 11.2716763 11.70074585 9.901032398 13.79140514
AB03 AB Level1 11.2716763 10.13968107 8.807718178 11.64910875
BC01 BC Level1 11.2716763 13.98765486 11.41248954 17.03470972
BC02 BC Level1 11.2716763 11.16346301 9.725727975 12.78818917
BC03 BC Level1 11.2716763 10.86537285 8.718797682 13.47623528
BC04 BC Level1 11.2716763 9.144506109 8.013572333 10.41066547
BC05 BC Level1 11.2716763 11.90861324 10.16280247 13.90909326
AB04 AB Level2 9.648187633 5.8868717 3.90289612 8.808718252
AB05 AB Level2 9.648187633 6.094263969 4.292064865 8.604182751
AB06 AB Level2 9.648187633 6.991179045 5.120179622 9.493934609
AB07 AB Level2 9.648187633 7.147464451 5.034721041 10.07672303
AB08 AB Level2 9.648187633 6.522514246 4.807970317 8.787388707
BC06 BC Level2 9.648187633 7.830914636 6.034632868 10.11549577
BC07 BC Level2 9.648187633 8.007776457 6.261879722 10.15813104
BC08 BC Level2 9.648187633 9.2036592 6.975207878 12.06377729
BC09 BC Level2 9.648187633 8.544482107 6.216079509 11.66857708
BC10 BC Level2 9.648187633 8.565949206 6.322877926 11.53859169
;
run;

proc sgplot data=test NOAUTOLEGEND;
block x=site block=level/filltype=alternate
fillattrs=GraphAltBlock
altfillattrs=GraphBlock
transparency=0.7;
scatter x=site y=cpred_final/yerrorupper=cupper_final
yerrorlower=clower_final
MARKERATTRS=(symbol=squarefilled color=black size=5)
TRANSPARENCY=0.3
group=city;
xaxis grid label="Site" valuesrotate=vertical;
yaxis values=(0 to 20 by 5) grid label="Rate (%)" discreteorder=data;
refline obsmean;
format cpred_final 4.1;
title ' ';
run;

1 REPLY 1
ballardw
Super User

Since you apparently are trying to limit the line in the graph area you might consider adding the data points for the start and end points into the data set and add a VECTOR plot to connect the points. You'll likely want to use some options to display the resulting line segments as desired.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 622 views
  • 1 like
  • 2 in conversation