<?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 Data Averaging and monotonic increase in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911090#M359268</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to do some simple averaging of the existing dataset by certain grouping and bucketing, but I also need to ensure that the value of each bucket increases as buckets always increase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Col1 Col2;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2&lt;BR /&gt;2 2&lt;BR /&gt;3 1&lt;BR /&gt;4 1&lt;BR /&gt;5 3&lt;/P&gt;&lt;P&gt;6 3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Data I want are;&lt;/P&gt;&lt;P&gt;&amp;lt;=2 2&lt;/P&gt;&lt;P&gt;&amp;lt;=4 2&lt;/P&gt;&lt;P&gt;&amp;lt;=6 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that for the bucket with Col1 values between 2 and 4, the actual average is 1, which is less than the value (2) of the bucket for Col1 less than 2, so the final value for the 2nd bucket should be replaced with 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2024 09:59:16 GMT</pubDate>
    <dc:creator>fwu811</dc:creator>
    <dc:date>2024-01-10T09:59:16Z</dc:date>
    <item>
      <title>Data Averaging and monotonic increase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911090#M359268</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to do some simple averaging of the existing dataset by certain grouping and bucketing, but I also need to ensure that the value of each bucket increases as buckets always increase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Col1 Col2;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2&lt;BR /&gt;2 2&lt;BR /&gt;3 1&lt;BR /&gt;4 1&lt;BR /&gt;5 3&lt;/P&gt;&lt;P&gt;6 3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Data I want are;&lt;/P&gt;&lt;P&gt;&amp;lt;=2 2&lt;/P&gt;&lt;P&gt;&amp;lt;=4 2&lt;/P&gt;&lt;P&gt;&amp;lt;=6 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that for the bucket with Col1 values between 2 and 4, the actual average is 1, which is less than the value (2) of the bucket for Col1 less than 2, so the final value for the 2nd bucket should be replaced with 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911090#M359268</guid>
      <dc:creator>fwu811</dc:creator>
      <dc:date>2024-01-10T09:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Data Averaging and monotonic increase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911091#M359269</link>
      <description>&lt;P&gt;I don't understand, you say "for Col1 values between 2 and 4" but your desired output has &amp;lt;=4, these are not the same. How are the limits for &amp;lt;=2 and &amp;lt;=4 and &amp;lt;=6 chosen, or are they fixed? &lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 10:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911091#M359269</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-10T10:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Data Averaging and monotonic increase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911152#M359292</link>
      <description>&lt;P&gt;One possibility is to use a format to create the buckets and then use PROC SUMMARY and finally a data step for correction:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc format;
  value bucket 
    1-&amp;lt;3='2'
    3-&amp;lt;5='4'
    5-&amp;lt;7='6'
   ;
run;

proc summary nway data=have;
  class col1;
  var col2;
  format col1 bucket.;
  output out=avg(drop=_:) mean=;
run;

data want;
  set avg;
  retain _lastval;
  col2=max(col2,_lastval);
  _lastval=col2;
  col1=input(put(col1,bucket.),best32.);
  drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put in a line to replace the value of COL1 with the value displayed with the BUCKET. format, as that may make the data easier to work with afterwards.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 15:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/911152#M359292</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2024-01-10T15:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data Averaging and monotonic increase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/928264#M365214</link>
      <description>&lt;P&gt;It works and thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 11:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Averaging-and-monotonic-increase/m-p/928264#M365214</guid>
      <dc:creator>fwu811</dc:creator>
      <dc:date>2024-05-14T11:30:33Z</dc:date>
    </item>
  </channel>
</rss>

