<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Combine plots of proc glm and sgplot in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combine-plots-of-proc-glm-and-sgplot/m-p/532110#M145764</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=ldl;
	class trt;
	model ldl3mo = ldlbase trt;
run;

proc sgplot data=ldl;
	reg x=ldlbase y=ldl3mo / group = trt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is my code and my data set looks like as below. Ignore the first column; that's just the number of order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 339px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26762i029EFF0FAEE658C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to combine two plots: plain regression plot generated by proc reg and covariance plot generated by proc glm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you see plots below, scatter plots are identical. So I would like to know how to combine those regression lines on a single plot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 378px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26760iB62EEADCB37E2AF4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Fri, 01 Feb 2019 17:16:37 GMT</pubDate>
    <dc:creator>monona</dc:creator>
    <dc:date>2019-02-01T17:16:37Z</dc:date>
    <item>
      <title>Combine plots of proc glm and sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-plots-of-proc-glm-and-sgplot/m-p/532110#M145764</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=ldl;
	class trt;
	model ldl3mo = ldlbase trt;
run;

proc sgplot data=ldl;
	reg x=ldlbase y=ldl3mo / group = trt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is my code and my data set looks like as below. Ignore the first column; that's just the number of order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 339px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26762i029EFF0FAEE658C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to combine two plots: plain regression plot generated by proc reg and covariance plot generated by proc glm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you see plots below, scatter plots are identical. So I would like to know how to combine those regression lines on a single plot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 378px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26760iB62EEADCB37E2AF4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 17:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-plots-of-proc-glm-and-sgplot/m-p/532110#M145764</guid>
      <dc:creator>monona</dc:creator>
      <dc:date>2019-02-01T17:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combine plots of proc glm and sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-plots-of-proc-glm-and-sgplot/m-p/532139#M145777</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214996"&gt;@monona&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=ldl;
	class trt;
	model ldl3mo = ldlbase trt;
run;

proc sgplot data=ldl;
	reg x=ldlbase y=ldl3mo / group = trt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is my code and my data set looks like as below. Ignore the first column; that's just the number of order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 339px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26762i029EFF0FAEE658C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to combine two plots: plain regression plot generated by proc reg and covariance plot generated by proc glm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you see plots below, scatter plots are identical. So I would like to know how to combine those regression lines on a single plot.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can capture the data used by the regression procedures by using ods output and the graph name found in the documentation.&lt;/P&gt;
&lt;P&gt;For GLM the Analysis of Covariance plot is named Ancovaplot. so adding this statement to you GLM code:&lt;/P&gt;
&lt;PRE&gt;ods output ancovaplot=work.ancovaplot;&lt;/PRE&gt;
&lt;P&gt;Will create a data set named work.ancovaplot. Similarly you can create a data set from Proc Reg. You cleverly did not show your Proc Reg code so I can't guess which options or plots you requested and so won't guess which graphname you may want. The documentation for the procedure under details has a table of graphnames for each procedure and the options needed to create them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would need to combine the two data sets. Likely you would need to rename the predicted variable for one set.&lt;/P&gt;
&lt;P&gt;Conceptually&lt;/P&gt;
&lt;PRE&gt;data work.plot;
   set work.ancovaplot
       work.regplot (rename=(Predicted=RegPredicted))
   ;
run;

Proc sgplot data=work.plot;
   scatter x=ldlbase y=ldl30/ group=trt;
   series  x=ldlbase y=predicted/group=trt;
   series  x=ldlbase y=regpredicted/ group=trt;
run;&lt;/PRE&gt;
&lt;P&gt;There may be details involved like variable labels for the predicted values and such.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 18:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-plots-of-proc-glm-and-sgplot/m-p/532139#M145777</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-01T18:17:16Z</dc:date>
    </item>
  </channel>
</rss>

