<?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: Something similar to INF (from R) in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606192#M176000</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279633"&gt;@whs278&lt;/a&gt;&amp;nbsp; Are you after this by any chance. I don't know what R is. But I am taking a guess&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

PROC SQL;

 

CREATE TABLE WANT AS 

SELECT *, min(ifn(TYPE = 'APPLE',WEIGHT,.)) AS LIGHTEST_APPLE

FROM HAVE

GROUP BY SHOPPING_DATE;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Nov 2019 16:56:18 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-11-21T16:56:18Z</dc:date>
    <item>
      <title>Something similar to INF (from R) in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606190#M175999</link>
      <description>&lt;P&gt;Is there a way to code a missing value so that when comparing it to any numeric value it will be considered greater?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, I want something equivalent to an 'INF' in R.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some code to help explain what I want.&amp;nbsp; Let's say I want to find the lightest apple I bought on a given shopping date and I want to assign that value to every case in that shopping date group regardless of whether the item is an apple or not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I use the following code.&amp;nbsp; However, I want to make sure that if the lightest item in the shopping date group is not an apple, it won't be considered.&amp;nbsp; I do this by temporarily assigning all non-apple items a weight of "INF", i.e. some value greater than all possible apple weights.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CREATE TABLE WANT AS&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT *, MIN(CASE WHEN TYPE = 'APPLE', WEIGHT, ELSE INF) AS LIGHTEST_APPLE&lt;/P&gt;&lt;P&gt;FROM HAVE&lt;/P&gt;&lt;P&gt;GROUP BY SHOPPING_DATE;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My only issue is that SAS does not have anything that I know that is equivalent to "INF" in R.&amp;nbsp; Is there a better way to accomplish this same goal in SAS?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for any help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 16:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606190#M175999</guid>
      <dc:creator>whs278</dc:creator>
      <dc:date>2019-11-21T16:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Something similar to INF (from R) in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606192#M176000</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279633"&gt;@whs278&lt;/a&gt;&amp;nbsp; Are you after this by any chance. I don't know what R is. But I am taking a guess&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

PROC SQL;

 

CREATE TABLE WANT AS 

SELECT *, min(ifn(TYPE = 'APPLE',WEIGHT,.)) AS LIGHTEST_APPLE

FROM HAVE

GROUP BY SHOPPING_DATE;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 16:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606192#M176000</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-21T16:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Something similar to INF (from R) in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606201#M176001</link>
      <description>&lt;P&gt;SAS has 28 missing values. Normal missing value is represented by period and the others by a period followed by a single letter or an underscore.&amp;nbsp; You can use anyone of them to mean positive infinity if you want.&amp;nbsp; So you could decide to use .I to represent positive infinity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But note that all missing values are considered less than any actual number when compared with an inequality operator.&amp;nbsp; And they are all ignored by the MIN() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE WANT AS 
  SELECT
    SHOPPING_DATE
  , MIN(CASE WHEN TYPE = 'APPLE' then WEIGHT else . end) as LIGHTEST_APPLE
  , case when (missing(calculated LIGHTEST_APPLE)) then .I else . end 
 as LIGHTEST_APPLE_OR_INFINITY
  FROM HAVE
  GROUP BY SHOPPING_DATE
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 16:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606201#M176001</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-21T16:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Something similar to INF (from R) in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606203#M176003</link>
      <description>&lt;P&gt;INF in R is infinity, so you want to put some value that is very high. Simply give a very high number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as 
select *, min(case when sex='M' then Height else 9999999 end)  as least
from sashelp.class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or if your not sure about giving a high number then give the max from that table itself so that it will not be min.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as 
select *, min(case when sex='M' then Height else (select max(height)+99 from sashelp.class) end)  as least
from sashelp.class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 16:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606203#M176003</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-11-21T16:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Something similar to INF (from R) in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606210#M176007</link>
      <description>&lt;P&gt;I think you may just need to recast how you use MIN. MIn will return the lowest non-missing value if there are any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But without data I'm not sure how to recast your specific query.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 17:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Something-similar-to-INF-from-R-in-SAS/m-p/606210#M176007</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-21T17:08:09Z</dc:date>
    </item>
  </channel>
</rss>

