<?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 Re: How to divide plot into smaller equal segment and find area under the curve? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317568#M21373</link>
    <description>&lt;PRE&gt;

data sample;
infile cards truncover expandtabs;
input X Y;
cards;
29 21
18 23
28 24
16 26
3 27
18 29
2 33
3 37
26 39
2 42
25 47
9 54
13 57
17 58
29 60
5 63
23 66
4 69
3 72
17 73
7 73
12 72
8 69
20 66
12 63
8 60
28 58
3 57
18 54
11 47
21 42
8 39
1 37
16 29
3 27
17 22
3 19
6 17
19 14
18 10
;
run;

proc sort data=sample ;
by x;
run;

proc sgplot data=sample;
needle x=x y=y;
run;

data Trapezoidal;
    set sample end=last;
    dif_x=dif(x); 
    mean_y=mean(lag(y),y);
    integral + (dif_x*mean_y);
    if last then putlog 'area under curve is ' integral;
run;

&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Dec 2016 11:45:48 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-12-08T11:45:48Z</dc:date>
    <item>
      <title>How to divide plot into smaller equal segment and find area under the curve?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317515#M21365</link>
      <description>&lt;P&gt;For the following data, what I am trying to learn are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. plot and find area under the curve (which is calculated using either 1. Simpson's rule (&lt;A href="https://en.wikipedia.org/wiki/Simpson%27s_rule" target="_blank"&gt;https://en.wikipedia.org/wiki/Simpson%27s_rule&lt;/A&gt;) or, 2. Trapezoidal rule (&lt;A href="https://en.wikipedia.org/wiki/Trapezoidal_rule)" target="_blank"&gt;https://en.wikipedia.org/wiki/Trapezoidal_rule)&amp;nbsp;&lt;/A&gt; - Not sure if there are SAS's inbuilt functions for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Find the mid point on the plot, divide the plot into two 'A' and 'B' and then divide each of 'A' and 'B' in &lt;STRONG&gt;equal smaller segments&lt;/STRONG&gt; (like black lines on the plot for section 'A' shown in the below pic, and calculate area for each segment (say Seg1 = xx&amp;nbsp; mm2, Seg1 = xx1&amp;nbsp; mm2 and so forth)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6275iFE730E0DA6D91B33/image-size/original?v=v2&amp;amp;px=-1" alt="sas.png" title="sas.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
infile cards truncover expandtabs;
input X Y;
cards;
29 21
18 23
28 24
16 26
3 27
18 29
2 33
3 37
26 39
2 42
25 47
9 54
13 57
17 58
29 60
5 63
23 66
4 69
3 72
17 73
7 73
12 72
8 69
20 66
12 63
8 60
28 58
3 57
18 54
11 47
21 42
8 39
1 37
16 29
3 27
17 22
3 19
6 17
19 14
18 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying something like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Trapezoidal;
    set x_y end=last;
    retain integral;
    lag_x=lag(x); lag_y = lag(y);
    if _N_ eq 1 then integral = 0;
    else integral = integral + (x - lag_x) * (y + lag_y) / 2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317515#M21365</guid>
      <dc:creator>imanojkumar1</dc:creator>
      <dc:date>2016-12-08T08:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide plot into smaller equal segment and find area under the curve?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317568#M21373</link>
      <description>&lt;PRE&gt;

data sample;
infile cards truncover expandtabs;
input X Y;
cards;
29 21
18 23
28 24
16 26
3 27
18 29
2 33
3 37
26 39
2 42
25 47
9 54
13 57
17 58
29 60
5 63
23 66
4 69
3 72
17 73
7 73
12 72
8 69
20 66
12 63
8 60
28 58
3 57
18 54
11 47
21 42
8 39
1 37
16 29
3 27
17 22
3 19
6 17
19 14
18 10
;
run;

proc sort data=sample ;
by x;
run;

proc sgplot data=sample;
needle x=x y=y;
run;

data Trapezoidal;
    set sample end=last;
    dif_x=dif(x); 
    mean_y=mean(lag(y),y);
    integral + (dif_x*mean_y);
    if last then putlog 'area under curve is ' integral;
run;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2016 11:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317568#M21373</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-08T11:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide plot into smaller equal segment and find area under the curve?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317581#M21374</link>
      <description>Thanks for your help KSharp. I am just wondering why needle chart used and not line plot. Also, can we plot a vertical line (on X axis, at Y=MaxVal) in the middle of the plot.</description>
      <pubDate>Thu, 08 Dec 2016 12:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317581#M21374</guid>
      <dc:creator>imanojkumar1</dc:creator>
      <dc:date>2016-12-08T12:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to divide plot into smaller equal segment and find area under the curve?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317796#M21376</link>
      <description>&lt;P&gt;Because that would be messed up .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really suggest you post it at ODS Graphic forum.&lt;/P&gt;&lt;P&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data sample;
infile cards truncover expandtabs;
input X Y;
cards;
29 21
18 23
28 24
16 26
3 27
18 29
2 33
3 37
26 39
2 42
25 47
9 54
13 57
17 58
29 60
5 63
23 66
4 69
3 72
17 73
7 73
12 72
8 69
20 66
12 63
8 60
28 58
3 57
18 54
11 47
21 42
8 39
1 37
16 29
3 27
17 22
3 19
6 17
19 14
18 10
;
run;

proc sort data=sample ;
by x;
run;
proc sql;
select mean(x) into : x from sample ;
quit;
proc sgplot data=sample;
needle x=x y=y;
spline x=x y=y / lineattrs=graphdata4(thickness=4);
refline &amp;amp;x / axis=x lineattrs=(color=red thickness=4);
run;

data Trapezoidal;
    set sample end=last;
    dif_x=dif(x); 
    mean_y=mean(lag(y),y);
    integral + (dif_x*mean_y);
    if last then putlog 'area under curve is ' integral;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 04:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-divide-plot-into-smaller-equal-segment-and-find-area/m-p/317796#M21376</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-09T04:46:12Z</dc:date>
    </item>
  </channel>
</rss>

