BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
craig159753
Quartz | Level 8

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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.

craig159753
Quartz | Level 8
This does help, I can also use the log axis wit the regression plot too. Thank you.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2494 views
  • 0 likes
  • 2 in conversation