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

Dear All,

I would like to plot the Drug PK concentration versus QTcF(a index of ECG) for each Subject over time. PK concentration will use the Y2 axis as the scale mark while QTcF use Y axis as the scale, the x axis will be used at the same time by PK and QTcF for each subject (see below graph), however I searched the Guidelines and found no way to do so. I guess the only option can reach this target is to use the GTL, but I am not experienced on this. I am wondering we need to use the Layout datapanel with Layout Overlay together in GTL?

Hope you can  help me.

Regards,

Frank

qtchangeandconc.png

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Here is a very simple example that you give you the ability to produce your plot. Let me know if you have any questions about it.

Thanks!

Dan

proc template;

define statgraph y2panel;

begingraph;

layout datapanel classvars=(sex) / columns=2 headerlabeldisplay=value;

  layout prototype;

    seriesplot x=name y=height / lineattrs=graphdata1 display=(markers);

    seriesplot x=name y=weight / yaxis=y2 lineattrs=graphdata2 display=(markers);

  endlayout;

endlayout;

endgraph;

end;

run;

proc sgrender data=sashelp.class template=y2panel; run;

View solution in original post

10 REPLIES 10
DanH_sas
SAS Super FREQ

Here is a very simple example that you give you the ability to produce your plot. Let me know if you have any questions about it.

Thanks!

Dan

proc template;

define statgraph y2panel;

begingraph;

layout datapanel classvars=(sex) / columns=2 headerlabeldisplay=value;

  layout prototype;

    seriesplot x=name y=height / lineattrs=graphdata1 display=(markers);

    seriesplot x=name y=weight / yaxis=y2 lineattrs=graphdata2 display=(markers);

  endlayout;

endlayout;

endgraph;

end;

run;

proc sgrender data=sashelp.class template=y2panel; run;

Linlin
Lapis Lazuli | Level 10

Hi Dan,

Below is waht I got by your code. why the graph on the left labeled as 'M'? isn't for all students? Thanks!

class.png

DanH_sas
SAS Super FREQ

Because some are male and some are female. To have only female names for the "F" cell and male names for the "M" cell, add COLUMNDATARANGE=UNION to the LAYOUT DATAPANEL after the "/". Sorry about the confusion.

-- Dan

DanH_sas
SAS Super FREQ

Note, however, for the original use case that was posted, the COLUMNDATARANGE option should not be used. That option improves the output for the data I used in my example,

Jack2012
Obsidian | Level 7

Dear Linlin,

I am very glad you can provide this question, which is helpful when I did my plot. Thank you.

Regards,

Frank

Jack2012
Obsidian | Level 7

Dear Dan,

Your answer is quite helpful, but may I ask how to add legend below the plot (like red line is Height and blue is weight)?

I just read the SAS guideline book  and it impressed me only if we use the OVERYLAY layout, can we add the legend, is this the case? If so, does this there is no way to add the legend below the figure?

Thank you so much.

Frank

DanH_sas
SAS Super FREQ

Sorry, I forgot to add the legend. Here you go:

proc template;

define statgraph y2panel;

begingraph;

layout datapanel classvars=(sex) / columns=2 headerlabeldisplay=value;

  layout prototype;

    seriesplot x=name y=height / lineattrs=graphdata1 display=(markers) name="a";

    seriesplot x=name y=weight / yaxis=y2 lineattrs=graphdata2 display=(markers) name="b";

  endlayout;

  sidebar / spacefill=false;

     discretelegend "a" "b";

   endsidebar;

endlayout;

endgraph;

end;

run;

proc sgrender data=sashelp.class template=y2panel; run;

Jack2012
Obsidian | Level 7

Dear Dan,

May I seek your answer to 'How can I re-value the scale in the y2 axis? For example, in the PROC GPLOT, we can set the values list in the axis property, but after I read the documentation, it seems we can not use this in PROC TEMPLATE'. Any comment are appreciated.

Regards,
Frank

DanH_sas
SAS Super FREQ

Yes, you can set the axis tick values in GTL. If you are in a DATA PANEL, like the example above, use the TICKVALUELIST option inside either the ROWAXISOPTS or COLUMNAXISOPTS option, depending on the axis you want to control. There is also a VIEWMIN/VIEWMAX option to control the limits of the axis. For layout OVERLAYs, you would use the same options inside of XAXISOPTS/YAXISOPTS/X2AXISOPTS/Y2AXISOPTS. Does this answer your question?

Thanks!

Dan

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
  • 10 replies
  • 2185 views
  • 5 likes
  • 3 in conversation