<?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 Adding a trend line to a series plot proc sgplot in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-trend-line-to-a-series-plot-proc-sgplot/m-p/825408#M326040</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;assuming I have this code and I wish to add a linear such as a regression line to show the trend of the curve&lt;/P&gt;
&lt;P&gt;how do I do that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines;
input year 4. pats_stage1_3 pats_total 3. ;
datalines;
1999 150 300
2000 112 369
2001 236 426
2002 121 400
2003 330 520
2004 280 500
;
run;


proc sgplot data=have noborder;

series x=year y=pats_stage1_3 / lineattrs=(color=blue);
series x=year y=pats_total /  lineattrs=(color=green) ;

xaxis  type=discrete display=(nolabel) discreteorder=data offsetmin=0.1 offsetmax=0.1 ;

yaxis display =(nolabel) values=(0 to 600 by 100) valueattrs=(family=arial size=5pt ) minor grid ;

keylegend / location=outside position=bottom title="" valueattrs=(size=7pt family=arial) outerpad=(top=0.2cm) noborder;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2022 10:49:31 GMT</pubDate>
    <dc:creator>Anita_n</dc:creator>
    <dc:date>2022-07-26T10:49:31Z</dc:date>
    <item>
      <title>Adding a trend line to a series plot proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-trend-line-to-a-series-plot-proc-sgplot/m-p/825408#M326040</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;assuming I have this code and I wish to add a linear such as a regression line to show the trend of the curve&lt;/P&gt;
&lt;P&gt;how do I do that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines;
input year 4. pats_stage1_3 pats_total 3. ;
datalines;
1999 150 300
2000 112 369
2001 236 426
2002 121 400
2003 330 520
2004 280 500
;
run;


proc sgplot data=have noborder;

series x=year y=pats_stage1_3 / lineattrs=(color=blue);
series x=year y=pats_total /  lineattrs=(color=green) ;

xaxis  type=discrete display=(nolabel) discreteorder=data offsetmin=0.1 offsetmax=0.1 ;

yaxis display =(nolabel) values=(0 to 600 by 100) valueattrs=(family=arial size=5pt ) minor grid ;

keylegend / location=outside position=bottom title="" valueattrs=(size=7pt family=arial) outerpad=(top=0.2cm) noborder;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 10:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-trend-line-to-a-series-plot-proc-sgplot/m-p/825408#M326040</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2022-07-26T10:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a trend line to a series plot proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-trend-line-to-a-series-plot-proc-sgplot/m-p/825426#M326049</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p0mn6vl6clqbgyn1ivs69lezdxhf.htm" target="_blank" rel="noopener"&gt;REG statements&lt;/A&gt; like these&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;reg x=year y=pats_stage1_3 / nomarkers lineattrs=(color=blue  pattern=dash) legendlabel='Regr. stage 1-3';
reg x=year y=pats_total    / nomarkers lineattrs=(color=green pattern=dash) legendlabel='Regr. total';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to your PROC SGPLOT step and remove the &lt;FONT face="courier new,courier"&gt;type=discrete&lt;/FONT&gt; option from the XAXIS statement to make them work.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 13:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-trend-line-to-a-series-plot-proc-sgplot/m-p/825426#M326049</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-26T13:04:56Z</dc:date>
    </item>
  </channel>
</rss>

