<?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: MIN function not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384410#M91785</link>
    <description>&lt;P&gt;It is just doing what you asked. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider this two observation dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input regsion $ amt ;
cards;
SOU 100
NOR 150
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first CASE will return 0 for the second row and the second CASE will return 0 for the first row.&lt;/P&gt;
&lt;P&gt;You should use missing value instead of 0 when the region does not match the target minimum.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;,min(case when region = 'SOU' then amt else . end) as MIN_sou
,min(case when region = 'NOR' then amt else . end) as MIN_nor&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You probably should have done the same for your MAX() calculations, but perhaps you didn't have any regions where the actual maximum amount was negative you didn't notice it wasn't working.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 19:49:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-07-31T19:49:29Z</dc:date>
    <item>
      <title>MIN function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384404#M91780</link>
      <description>&lt;P&gt;I use max function in Proc SQL its working fine.&lt;BR /&gt;MIN function not working properly giving wrong results. Some of them giving me 0 instead of values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;min(case&amp;nbsp;when&amp;nbsp;region =&amp;nbsp;'SOU'&amp;nbsp;then&amp;nbsp;amt&amp;nbsp;else&amp;nbsp;0&amp;nbsp;end)&amp;nbsp;as&amp;nbsp;MIN_sou,&amp;nbsp;&lt;BR /&gt;min(case&amp;nbsp;when&amp;nbsp;region =&amp;nbsp;'NOR'&amp;nbsp;then&amp;nbsp;amt&amp;nbsp;else&amp;nbsp;0&amp;nbsp;end)&amp;nbsp;as&amp;nbsp;MIN_nor&lt;BR /&gt;,&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384404#M91780</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-07-31T19:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: MIN function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384406#M91782</link>
      <description>&lt;P&gt;It could be that 0 is exactly what you asked for with your code (although it may not be what you wanted to get).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But ... we don't know what's in your data, and we don't really know what you want to get as a result ... so could you please show us a representative portion of your data, and explain exactly what result you want to get?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384406#M91782</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T19:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: MIN function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384410#M91785</link>
      <description>&lt;P&gt;It is just doing what you asked. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider this two observation dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input regsion $ amt ;
cards;
SOU 100
NOR 150
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first CASE will return 0 for the second row and the second CASE will return 0 for the first row.&lt;/P&gt;
&lt;P&gt;You should use missing value instead of 0 when the region does not match the target minimum.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;,min(case when region = 'SOU' then amt else . end) as MIN_sou
,min(case when region = 'NOR' then amt else . end) as MIN_nor&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You probably should have done the same for your MAX() calculations, but perhaps you didn't have any regions where the actual maximum amount was negative you didn't notice it wasn't working.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384410#M91785</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-31T19:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: MIN function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384425#M91794</link>
      <description>&lt;P&gt;Thank you for the reply!..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my data look like:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;acct &amp;nbsp;date &amp;nbsp; &amp;nbsp;region &amp;nbsp; &amp;nbsp;amt&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 5/21 &amp;nbsp; &amp;nbsp; &amp;nbsp;sou &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 5/21 &amp;nbsp; &amp;nbsp; &amp;nbsp;nor &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 6/22 &amp;nbsp; &amp;nbsp; &amp;nbsp;sou &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 6/22 &amp;nbsp; &amp;nbsp; &amp;nbsp;sou &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 5/21 &amp;nbsp; &amp;nbsp; &amp;nbsp;nor &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Output want:&lt;/P&gt;&lt;P&gt;min_sou min_nor&lt;BR /&gt;20 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 20:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384425#M91794</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-07-31T20:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: MIN function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384428#M91796</link>
      <description>&lt;P&gt;I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;hit the nail on the head, if you set it to 0 if missing, that will always be the minimum. Set it to missing instead.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 20:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384428#M91796</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-31T20:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: MIN function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384432#M91800</link>
      <description>&lt;P&gt;Thank you..It worked!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 20:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MIN-function-not-working/m-p/384432#M91800</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-07-31T20:36:17Z</dc:date>
    </item>
  </channel>
</rss>

