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.

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
  • 2 replies
  • 486 views
  • 0 likes
  • 2 in conversation