<?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: finding the midpoint of observations in a three year period in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447195#M112280</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196171"&gt;@89974114&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;There must be a function in the proc means or a proc command which allows you to find the weighted average with respect to the observation length&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the actual concern is that your actual problem involves more than 3 variables whose names are actually ordinal data values then you might be looking at an array to hold the listed variables and compare the mean to an iteratively created cumulative total.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2018 17:03:39 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-03-20T17:03:39Z</dc:date>
    <item>
      <title>finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446883#M112200</link>
      <description>&lt;P&gt;I have a dataset which represents the volume of sales over three years:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data test;
input one two three average;
datalines;
10 20 30 .
20 30 40 .
10 30 50 .
10 10 10 .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm looking for a way to find the middle point of the three years, the average sale point&lt;/P&gt;&lt;P&gt;the updated dataset would read&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data test;
input one two three average;
datalines;
10 20 30 2
20 30 40 1.5
10 30 50 2.1
10 10 10 1.5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So essentially looking for what part of the three years the halfway point of the sales occurred.&lt;/P&gt;&lt;P&gt;Appreciate.&lt;/P&gt;&lt;P&gt;EDIT: what I've been trying with the weight and proc means&lt;/P&gt;&lt;P&gt;I've been trying to use proc means and weight function but it doesn't give me the average point of the three years&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;proc means data=test noprint;
var one two three;
var one+two+three=total;
var (one+two+three)/3=Average; 
var Average/weight=Average_Year;

output out=testa2
    sum(Total) = 
    mean(Total) = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 17:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446883#M112200</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-19T17:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446884#M112201</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196171"&gt;@89974114&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm looking for a way to find the middle point of the three years, the average sale point&lt;/P&gt;
&lt;P&gt;the updated dataset would read&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;data test;
input one two three average;
datalines;
10 20 30 2
20 30 40 1.5
10 30 50 2.1
10 10 10 1.5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have to admit I am not following this, I don't see how you have computed the average value.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 17:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446884#M112201</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-19T17:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446887#M112203</link>
      <description>&lt;P&gt;so the first value would be 10+20+30=60, then midway is 30 which is 10+20 so 2 years&lt;BR /&gt;&lt;BR /&gt;I'm looking for the average point throughout the three years based on the volume of sales&lt;BR /&gt;&lt;BR /&gt;the second would be 20+30+40=90 / 2 = 45 ,&lt;BR /&gt;&lt;BR /&gt;45-20 = 25 then 25/30 = 5/6th of a year so my mistake the second line should be 1 + 5/6th years&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 17:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446887#M112203</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-19T17:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446888#M112204</link>
      <description>&lt;P&gt;So i'm thinking if each volume is given a weight based on total volume, how far through the three years is the middle point&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 17:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446888#M112204</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-19T17:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446928#M112212</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;so the first value would be 10+20+30=60, then midway is 30 which is 10+20 so 2 years&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Still not following this at all.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;the second would be 20+30+40=90 / 2 = 45 ,&lt;BR /&gt;&lt;BR /&gt;45-20 = 25 then 25/30 = 5/6th&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So in the first example, there is no subtraction happening, but in this example there is a subtraction in the math?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 19:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446928#M112212</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-19T19:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446956#M112218</link>
      <description>&lt;P&gt;So,&amp;nbsp;I guess you want something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input one two three;
midpoint = sum(one, two, three) / 2;
if midpoint &amp;lt; one then halfSalesPoint = midpoint / one;
else if midpoint &amp;lt; one + two then halfSalesPoint = 1 + (midpoint - one) / two;
else halfSalesPoint = 2 + (midpoint - one - two) / three;
drop midpoint;
datalines;
10 20 30
20 30 40
10 30 50
10 10 10
;

proc print data=test; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 18:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/446956#M112218</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-20T18:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447009#M112224</link>
      <description>&lt;P&gt;Maybe think of it like a cumulative frequency curve, as you add all three observations together you move from 0 to 100% of the value, think of the x axis as 1-3 years and the y-axis as 0 to 100%, you are looking for the point that aligns 50% on the y-axis and the middle point of the x-axis.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 06:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447009#M112224</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-20T06:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447012#M112225</link>
      <description>&lt;P&gt;I can't fault that it gives the right answers, appreciate. I am wondering if there is a more efficient solution though as I'll be performing this datastep with millions of entries&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 06:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447012#M112225</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-20T06:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447176#M112270</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196171"&gt;@89974114&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I can't fault that it gives the right answers, appreciate. I am wondering if there is a more efficient solution though as I'll be performing this datastep with millions of entries&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is inefficient about the accepted solution?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 15:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447176#M112270</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-20T15:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447177#M112271</link>
      <description>&lt;P&gt;There must be a function in the proc means or a proc command which allows you to find the weighted average with respect to the observation length&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 15:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447177#M112271</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-20T15:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447187#M112276</link>
      <description>&lt;P&gt;I just don't see how this pr/oblem can be expressed as a weighted average. To me,&amp;nbsp;the solution to your problem amounts to finding&amp;nbsp;the inverse of a piecewise linear function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This little datastep should run very fast. I doubt that any proc can do much better.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 16:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447187#M112276</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-20T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447195#M112280</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196171"&gt;@89974114&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;There must be a function in the proc means or a proc command which allows you to find the weighted average with respect to the observation length&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the actual concern is that your actual problem involves more than 3 variables whose names are actually ordinal data values then you might be looking at an array to hold the listed variables and compare the mean to an iteratively created cumulative total.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 17:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447195#M112280</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-20T17:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: finding the midpoint of observations in a three year period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447335#M112356</link>
      <description>&lt;P&gt;I was being unreasonably pedantic yesterday, my apologies.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 07:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-the-midpoint-of-observations-in-a-three-year-period/m-p/447335#M112356</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-21T07:01:25Z</dc:date>
    </item>
  </channel>
</rss>

