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
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;
Use the LINEPARM statement.
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;
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.