Hi,
I am trying to plot a SCATTERPLOT with a slope, via LINEPARM. This works perfectly for a linear axis, but does not like it when I change the Y axis to a logarithmic axis. Can anyone help?
proc template;
define statgraph layoutoverlay;
%* Define Dynamic labels;
dynamic xlabel ylabel ;
%* Begin the graph template;
begingraph / border = false designwidth = 900px designheight = 530px;
%* Title;
entrytitle "My title " / textattrs = (family = "Courier new" weight=bold size=10);
layout overlay / /* X axis */
xaxisopts = (label = xlabel
labelattrs = (family = "arial" weight=bold size=10)
labelfitpolicy = splitalways
labelsplitchar = "|"
display = (label ticks tickvalues)
type = linear
linearopts = (viewmin=0 viewmax=50)
tickvalueattrs = (family = "arial" size=9)
offsetmin = 0.05
offsetmax = 0.05)
/* Y axis */
yaxisopts = (label = ylabel
labelattrs = (family = "arial" weight=bold size=10)
labelfitpolicy = splitalways
labelsplitchar = "|"
display = (label ticks tickvalues)
type = log
logopts=(base=10
tickintervalstyle=logexpand
thresholdmin=1 thresholdmax=1)
tickvalueattrs = (family = "arial" size=9)
offsetmin = 0.05
offsetmax = 0.05);
%* Line Plot;
scatterplot x=dose y=result / group = mygroup
groupdisplay = overlay
name = "scatter";
%* Diagonal line;
lineparm x=0 y=intercept_log slope=slope_log / clip=true;
%* Legend;
discretelegend "scatter" / title = "Treatment: "
titleattrs = (family = "arial" weight=bold size=10)
valueattrs = (family = "arial" size=9)
location = outside
halign = center
valign = bottom;
endlayout;
endgraph;
end;
run;
%* Produce output;
proc sgrender
data = my_data
template = layoutoverlay;
dynamic xlabel = "X Axis"
ylabel = "Y Axist";
run;
When running this with the Y axis defined as log I get
WARNING: LINEPARM statement has a conflict with the axis type.
After some googling I could only find this, which talks about "working with transformed values", but I am merely the programmer not the statistician.
As a note, my INTERCEPT=5.05 and SLOPE=4.17 which come directly from a PROC REG which used values converted using the LOG10 function, and ALPHA=0.1.
Any help would be greatly appreciated.
The WARNING alerts you to the fact that you can't use a LINEPARM statement if one of the axes are TYPE=LOG.
You can use a DATA step to create a new variable LogResult = log(Result). Then use TYPE=LINEAR for the YAXISOPTS and plot the regression line for X=Dose and Y=LogResult.
The WARNING alerts you to the fact that you can't use a LINEPARM statement if one of the axes are TYPE=LOG.
You can use a DATA step to create a new variable LogResult = log(Result). Then use TYPE=LINEAR for the YAXISOPTS and plot the regression line for X=Dose and Y=LogResult.
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!
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.