<?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: When I use IFC function, the log report the missing value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638870#M189992</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;described the root cause. For your specific sample code using format dtdate. would allow you to not use function datepart() which throws the note. Using format dtdate. even removes the need for conditional logic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  a="20DEC2019:00:00:00.000"dt;output;
  a=.;output;
  format a DATETIME22.3;
run;

data b;
  set a;
  c=put(a, dtdate9.);
/*  c=ifc(a ne .,put(a,dtdate9.),'');*/
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Apr 2020 04:51:17 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-04-10T04:51:17Z</dc:date>
    <item>
      <title>When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638858#M189989</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why I run the data B, the log report " Missing values were generated as a result of performing an operation on missing value"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the log of data C is clean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use the data B with the clean log. Thanks.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data a;
  a="20DEC2019:00:00:00.000"dt;output;
  a=.;output;
  format a DATETIME22.3;
run;

data b;
  set a;
  c=ifc(a ne .,put(datepart(a),date9.),'');
run;

data c;
  set a ;
  if a ne . then c=put(datepart(a),date9.);
  else c='';
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 02:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638858#M189989</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2020-04-10T02:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638869#M189991</link>
      <description>&lt;P&gt;Sadly, SAS made the decision that the if&lt;EM&gt;x&lt;/EM&gt;() functions were executed by the compiler like every other function.&lt;/P&gt;
&lt;P&gt;This means that all the function parameters are processed all the time.&lt;/P&gt;
&lt;P&gt;The consequences of this decision are:&lt;/P&gt;
&lt;P&gt;1. Your B code generates a message, as you have observed. There is no doubt that this undermines the usefulness of the function.&lt;/P&gt;
&lt;P&gt;2. There is a performance cost as both the true and false parameters are executed, when only one of them is ever needed.&lt;/P&gt;
&lt;P&gt;I can't think of a good reason for this decision.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 06:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638869#M189991</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-10T06:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638870#M189992</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;described the root cause. For your specific sample code using format dtdate. would allow you to not use function datepart() which throws the note. Using format dtdate. even removes the need for conditional logic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  a="20DEC2019:00:00:00.000"dt;output;
  a=.;output;
  format a DATETIME22.3;
run;

data b;
  set a;
  c=put(a, dtdate9.);
/*  c=ifc(a ne .,put(a,dtdate9.),'');*/
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 04:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638870#M189992</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-04-10T04:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638871#M189993</link>
      <description>&lt;P&gt;I see one advantage: you can use lag() "conditionally".&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 05:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638871#M189993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-10T05:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638873#M189995</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; You found the silver lining! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 05:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638873#M189995</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-10T05:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638875#M189997</link>
      <description>Thanks for your answer！</description>
      <pubDate>Fri, 10 Apr 2020 05:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638875#M189997</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2020-04-10T05:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638889#M190000</link>
      <description>&lt;P&gt;I even think that this behavior is the explicit purpose of the ifc and ifn functions. Otherwise a simple if-then-else is all that's needed, and we've been coding that since the beginning of non-assembler programming languages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When a function is called, the argument&amp;nbsp;&lt;EM&gt;values&lt;/EM&gt; need to be pushed onto the stack, and the function retrieves them from there. If you do not want this to happen, the data step compiler would need extra coding to recognize the ifc/ifn function and then translate the whole call into a normal if-then-else statement; something that the programmer can easily do on their own, if non-execution of a branch is wanted.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 08:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638889#M190000</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-10T08:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638898#M190004</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; Your explanation makes sense.&lt;/P&gt;
&lt;P&gt;I find a code such as&lt;/P&gt;
&lt;PRE&gt;VAR = ifn(&amp;amp;test1, 1
    , ifn(&amp;amp;test2, 2
    , ifn(&amp;amp;test3, 3, 4 )));
&lt;/PRE&gt;
&lt;P&gt;much more legible than&lt;/P&gt;
&lt;PRE&gt;if      &amp;amp;test1 then VAR= 1;
else if &amp;amp;test2 then VAR= 2;
else if &amp;amp;test3 then VAR= 3;
else                VAR= 4;&lt;/PRE&gt;
&lt;P&gt;and I often use &lt;STRONG&gt;if&lt;/STRONG&gt;() just for this reason. The example given (dealing with missing values) is also a hindrance.&lt;/P&gt;
&lt;P&gt;So I wish the compiler behaved as if it found a &lt;STRONG&gt;if then&lt;/STRONG&gt; test; I don't think the extra compiler logic to identify this would be of any consequence.&lt;/P&gt;
&lt;P&gt;That's just me though. I understand your reasons and they are valid too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 11:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638898#M190004</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-10T11:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638910#M190010</link>
      <description>&lt;P&gt;Not sure I see how that is better pattern.&amp;nbsp; Turning logic into function calls might make sense in something like Excel spreadsheet where everything has to be a function.&amp;nbsp;&amp;nbsp;If it is just the symmetry you like then use a SELECT statement instead of nested if/then/else.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; Your explanation makes sense.&lt;/P&gt;
&lt;P&gt;I find a code such as&lt;/P&gt;
&lt;PRE&gt;VAR = ifn(&amp;amp;test1, 1
    , ifn(&amp;amp;test2, 2
    , ifn(&amp;amp;test3, 3, 4 )));
&lt;/PRE&gt;
&lt;P&gt;much more legible than&lt;/P&gt;
&lt;PRE&gt;if      &amp;amp;test1 then VAR= 1;
else if &amp;amp;test2 then VAR= 2;
else if &amp;amp;test3 then VAR= 3;
else                VAR= 4;&lt;/PRE&gt;
&lt;P&gt;and I often use &lt;STRONG&gt;if&lt;/STRONG&gt;() just for this reason. The example given (dealing with missing values) is also a hindrance.&lt;/P&gt;
&lt;P&gt;So I wish the compiler behaved as if it found a &lt;STRONG&gt;if then&lt;/STRONG&gt; test; I don't think the extra compiler logic to identify this would be of any consequence.&lt;/P&gt;
&lt;P&gt;That's just me though. I understand your reasons and they are valid too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 10 Apr 2020 12:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/638910#M190010</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-10T12:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: When I use IFC function, the log report the missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/639138#M190073</link>
      <description>&lt;P&gt;I agree that a function is not best suited for this kind of test.&lt;/P&gt;
&lt;P&gt;But it is much more legible in this case, imho.&lt;/P&gt;
&lt;P&gt;Hence my preference. I put legibility first here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2020 11:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-I-use-IFC-function-the-log-report-the-missing-value/m-p/639138#M190073</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-11T11:33:35Z</dc:date>
    </item>
  </channel>
</rss>

