<?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: SAS function equivalent to EXCEL function iferror() in Microsoft Integration with SAS</title>
    <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183139#M1549</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest you try the equivalent to Excel's "isblank" instead of "iserror". Could look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data A;&lt;BR /&gt;&amp;nbsp; Input Birthdate:Date9.; Format Birthdate Date9.;&lt;BR /&gt;&amp;nbsp; Datalines;&lt;BR /&gt;&amp;nbsp; 01JAN2000&lt;BR /&gt;&amp;nbsp; 09SEP2006&lt;BR /&gt;&amp;nbsp; .&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Proc SQL;&lt;BR /&gt;&amp;nbsp; Create Table B As &lt;BR /&gt;&amp;nbsp; Select *, &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case When Missing (Birthdate) Then 22 Else &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YrDif(Birthdate,Today(),'Actual') End As Age &lt;BR /&gt;&amp;nbsp; From A;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Nov 2014 08:32:08 GMT</pubDate>
    <dc:creator>user24feb</dc:creator>
    <dc:date>2014-11-24T08:32:08Z</dc:date>
    <item>
      <title>SAS function equivalent to EXCEL function iferror()</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183138#M1548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could someone tell me an equivalent SAS function for the EXCEL function iferror(), which I could use in a PROC SQL variable assignment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, in an datastep if I have a SAS variable defined as: &lt;/P&gt;&lt;P&gt;AGE = YRDIF( birthdate, today(), 'ACTUAL');&lt;/P&gt;&lt;P&gt;but for some reason in my data the birthdate is missing, then I get an error. This does not stop SAS, but I would like it to put, for example, 22 (the average age) if the birthdate is missing. In a datastep I would write:&lt;/P&gt;&lt;P&gt;if missing(birthdate) then AGE = YRDIF( birthdate, today(), 'ACTUAL'); else AGE = 22;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, in a PROC SQL, how would I do this? All I can think of is if there were an equivalent SAS function like the EXCEL iferror() function, then I could do this in one line. In other words, I would like to write the "equivalent" of (using the EXCEL function):&lt;/P&gt;&lt;P&gt;AGE = iferror( YRDIF( birthdate, today(), 'ACTUAL'), 22); &lt;/P&gt;&lt;P&gt;If the first argument is null or error, then the second argument is returned for AGE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Ian.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 08:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183138#M1548</guid>
      <dc:creator>iank131</dc:creator>
      <dc:date>2014-11-24T08:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function equivalent to EXCEL function iferror()</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183139#M1549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest you try the equivalent to Excel's "isblank" instead of "iserror". Could look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data A;&lt;BR /&gt;&amp;nbsp; Input Birthdate:Date9.; Format Birthdate Date9.;&lt;BR /&gt;&amp;nbsp; Datalines;&lt;BR /&gt;&amp;nbsp; 01JAN2000&lt;BR /&gt;&amp;nbsp; 09SEP2006&lt;BR /&gt;&amp;nbsp; .&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Proc SQL;&lt;BR /&gt;&amp;nbsp; Create Table B As &lt;BR /&gt;&amp;nbsp; Select *, &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case When Missing (Birthdate) Then 22 Else &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YrDif(Birthdate,Today(),'Actual') End As Age &lt;BR /&gt;&amp;nbsp; From A;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 08:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183139#M1549</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-11-24T08:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function equivalent to EXCEL function iferror()</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183140#M1550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks very much. I just happened to find almost exactly the same solution after searching some more. Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 08:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183140#M1550</guid>
      <dc:creator>iank131</dc:creator>
      <dc:date>2014-11-24T08:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function equivalent to EXCEL function iferror()</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183141#M1551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a one line approach:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; birthday='01jan2012'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; birthday=.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yrdif(COALESCE(BIRTHDAY,'15JUL1992'd),today(),'actual') as AGE&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So coalesce takes the first non-null value from the list, birthday first, then your default, and caluculates on that value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 09:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183141#M1551</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-24T09:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS function equivalent to EXCEL function iferror()</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183142#M1552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 10:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/SAS-function-equivalent-to-EXCEL-function-iferror/m-p/183142#M1552</guid>
      <dc:creator>iank131</dc:creator>
      <dc:date>2014-11-24T10:34:45Z</dc:date>
    </item>
  </channel>
</rss>

