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

I have a scatterplot that needs a diagonal reference line (from 1,1 to MAXx,MAXy).  

 

My proc template:

 

proc template;
define statgraph XXXX;
begingraph ;

layout overlay / 
xaxisopts = (label='x-axis label' labelattrs=(family="Courier New" size=8pt weight=bold) tickvalueattrs=(family="Courier New" size=8pt weight=bold) linearopts = (tickvaluesequence = (start = 1 end = 10 increment = 1) 
viewmin = 1 viewmax = 10))
yaxisopts = (label="y-axis label" tickvalueattrs=(family="Courier New" size=8pt weight=bold) linearopts = (tickvaluesequence = (start = -10 end = 15 increment = 5) viewmin = -10 viewmax = 15));

entry halign=left ' ' / valign=top
textattrs=(family="Courier New" size=8pt weight=bold);
 
scatterplot x = pwk1 y = awk1 / markerattrs = (color=red symbol=circlefilled size=5) name="trt1" legendlabel="Avelumab";
scatterplot x = pwk2 y = awk2 / markerattrs = (color=blue symbol=circlefilled size=5) name="trt2" legendlabel="Avelumab + PLD";
scatterplot x = pwk3 y = awk3 / markerattrs = (color=green symbol=circlefilled size=5) name="trt3" legendlabel="PLD";

discretelegend "trt1" "trt2" "trt3"/ across=1 valueattrs=(family="Courier New" size=8pt weight=bold) valign=bottom halign=center location=outside;   endlayout; endgraph; end; run;

proc sgrender data=final template = xxxx;
run;
quit;

 

Can I use REFERENCELINE?  I've tried, but not sure if I'm not doing it correctly, or if it's not possible to use this statement. 

 

 

Thanks!

VCM

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Ammonite | Level 13

I have used lineparm when I need a diagonal reference line.  Example:

  define statgraph Stat.MDS.Graphics.Fit;
      notes "MDS Fit Plot";
      dynamic head;
      begingraph / designwidth=defaultdesignheight;
         entrytitle head;
         layout overlayequated / equatetype=square ;
            scatterplot y = FitData x = FitDist / markerattrs=(size=5px);
            lineparm slope=1 x=0 y=0 / clip=true extend=true lineattrs=graphReference;
            endlayout;
         dynamic _byline_ _bytitle_ _byfootnote_;
         if (_bytitle_) entrytitle _byline_ / textattrs=GraphValueText;
         else if (_byfootnote_) entryfootnote halign=left _byline_;
         endif; endif;
         endgraph;
      end;

View solution in original post

5 REPLIES 5
Jay54
Meteorite | Level 14

Use the LINEPARM statement.

VCM
Obsidian | Level 7 VCM
Obsidian | Level 7
Brilliant, worked perfectly! Thank you so much! 🙂
WarrenKuhfeld
Ammonite | Level 13

I have used lineparm when I need a diagonal reference line.  Example:

  define statgraph Stat.MDS.Graphics.Fit;
      notes "MDS Fit Plot";
      dynamic head;
      begingraph / designwidth=defaultdesignheight;
         entrytitle head;
         layout overlayequated / equatetype=square ;
            scatterplot y = FitData x = FitDist / markerattrs=(size=5px);
            lineparm slope=1 x=0 y=0 / clip=true extend=true lineattrs=graphReference;
            endlayout;
         dynamic _byline_ _bytitle_ _byfootnote_;
         if (_bytitle_) entrytitle _byline_ / textattrs=GraphValueText;
         else if (_byfootnote_) entryfootnote halign=left _byline_;
         endif; endif;
         endgraph;
      end;
VCM
Obsidian | Level 7 VCM
Obsidian | Level 7
That was the ticket, thank you so much! 🙂
ballardw
Super User

You should but it is a separate plot not part of scatterplot.

scatterplot x = pwk1 y = awk1 / markerattrs = (color=red symbol=circlefilled size=5) name="trt1" legendlabel="Avelumab";
scatterplot x = pwk2 y = awk2 / markerattrs = (color=blue symbol=circlefilled size=5) name="trt2" legendlabel="Avelumab + PLD";
scatterplot x = pwk3 y = awk3 / markerattrs = (color=green symbol=circlefilled size=5) name="trt3" legendlabel="PLD";

referenceline x= 5 / lineattrs=(thickness=3);

 

should place a vertical reference line at the value 5 on your horizontal axis (assuming 5 is in range) and would be a thickish line

 

If that does not work show the log.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2047 views
  • 0 likes
  • 4 in conversation