<?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 average a range observation ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-average-a-range-observation/m-p/731107#M227736</link>
    <description>&lt;P&gt;If below works for you will depend on your actual data.&lt;/P&gt;
&lt;P&gt;I've made the assumption that all values are in percent.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input pct $;
  cards;
15%
5
30
10-15%
;

data want(drop=_:);
  set have;
  length pct_n 8;
  pct=compress(pct,' %');
  _words=countw(pct,'-');
  do _i=1 to _words;
    pct_n=sum(pct_n,input(scan(pct,_i,'-'),best32.));
  end;
  pct_n=pct_n/(100*_words);
  format pct_n percent10.1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1617431494425.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56870iCC9F2C96F0513D66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1617431494425.png" alt="Patrick_0-1617431494425.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 03 Apr 2021 06:38:14 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-04-03T06:38:14Z</dc:date>
    <item>
      <title>How to average a range observation ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-average-a-range-observation/m-p/731103#M227733</link>
      <description>&lt;P&gt;I have a data with a column of percentages, the column in inconsistent. Some obs are discrete values like X% and some are ranges x % - y%. I have to take average of range obs. How can I do that ? Below is an example of my problem&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;input pct $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;15%&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;30&lt;/P&gt;&lt;P&gt;10-15%&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 06:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-average-a-range-observation/m-p/731103#M227733</guid>
      <dc:creator>Oj1698</dc:creator>
      <dc:date>2021-04-03T06:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to average a range observation ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-average-a-range-observation/m-p/731107#M227736</link>
      <description>&lt;P&gt;If below works for you will depend on your actual data.&lt;/P&gt;
&lt;P&gt;I've made the assumption that all values are in percent.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input pct $;
  cards;
15%
5
30
10-15%
;

data want(drop=_:);
  set have;
  length pct_n 8;
  pct=compress(pct,' %');
  _words=countw(pct,'-');
  do _i=1 to _words;
    pct_n=sum(pct_n,input(scan(pct,_i,'-'),best32.));
  end;
  pct_n=pct_n/(100*_words);
  format pct_n percent10.1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1617431494425.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56870iCC9F2C96F0513D66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1617431494425.png" alt="Patrick_0-1617431494425.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 06:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-average-a-range-observation/m-p/731107#M227736</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-03T06:38:14Z</dc:date>
    </item>
  </channel>
</rss>

