<?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 proc means in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114634#M23603</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using proc means to average values across multiple observations for each year. (see attached data). one complication is variable Horizon, some records have a special code -99, indicating this value might be missing or subject to error. In such cases, I want to average only those valid values, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. For year_FPE=1996, avgHORI=(5/304+4.951+2.386)/3 (excluding -99)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I modify the code below ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC MEANS DATA=id1300 NWAY noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLASS Security_ID&amp;nbsp;&amp;nbsp; YEAR_FPE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; VAR horizon Specificity count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; OUTPUT OUT=want&amp;nbsp; MEAN=avgHORI avgSPEC avgcount;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 18 Aug 2013 20:33:01 GMT</pubDate>
    <dc:creator>LanMin</dc:creator>
    <dc:date>2013-08-18T20:33:01Z</dc:date>
    <item>
      <title>proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114634#M23603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using proc means to average values across multiple observations for each year. (see attached data). one complication is variable Horizon, some records have a special code -99, indicating this value might be missing or subject to error. In such cases, I want to average only those valid values, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. For year_FPE=1996, avgHORI=(5/304+4.951+2.386)/3 (excluding -99)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I modify the code below ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC MEANS DATA=id1300 NWAY noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLASS Security_ID&amp;nbsp;&amp;nbsp; YEAR_FPE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; VAR horizon Specificity count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; OUTPUT OUT=want&amp;nbsp; MEAN=avgHORI avgSPEC avgcount;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Aug 2013 20:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114634#M23603</guid>
      <dc:creator>LanMin</dc:creator>
      <dc:date>2013-08-18T20:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114635#M23604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Add in a where statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PROC MEANS DATA=id1300 NWAY noprint;&lt;/P&gt;&lt;H3 style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="color: #0000ff;"&gt;where horizon ne -99;&lt;/SPAN&gt;&lt;/H3&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; CLASS Security_ID&amp;nbsp;&amp;nbsp; YEAR_FPE;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; VAR horizon Specificity count;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; OUTPUT OUT=want&amp;nbsp; MEAN=avgHORI avgSPEC avgcount;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Aug 2013 21:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114635#M23604</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-08-18T21:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114636#M23605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While Reeza's solution works, you would be well advised to change your data.&amp;nbsp; SAS supports special missing values, such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if horizon = -99 then horizon=.A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are 27 special missing values, .A through .Z, and ._ as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you change the -99 to .A, the PROC MEANS will automatically throw them out without the need for a WHERE statement.&amp;nbsp; This becomes especially useful if you have two analysis variables.&amp;nbsp; For example, suppose COUNT could also be -99, but not necessarily on the same observations having HORIZON = -99.&amp;nbsp; Then there would be no WHERE statement that could remove the proper observations.&amp;nbsp; But if you have changed all -99 values to a special missing value, PROC MEANS would know enough to leave them out of the calculations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Aug 2013 21:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114636#M23605</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-18T21:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114637#M23606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If there is any concern about the inefficiency of re-writing all the data to take advantage of the "Astounding" idea, just create a VIEW to convert those -99 into special missings and implement that complex formula at the same time. For as PROC MEANS reads the view, the special values and formula will be calculated "on the fly".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Neat&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 15:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114637#M23606</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-08-19T15:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114638#M23607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all of you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 00:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means/m-p/114638#M23607</guid>
      <dc:creator>LanMin</dc:creator>
      <dc:date>2013-08-20T00:29:36Z</dc:date>
    </item>
  </channel>
</rss>

