<?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: Conditional that evaluates two variables to create a new one in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702843#M25957</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input REPORTING_DT   ddmmyy10.  PRODUCT     $12.  ;
cards;
31/03/2018 bonds_0      
31/03/2018 bonds_1200   
31/03/2018 savings_0    
31/03/2018 savings_1200 
;
data want;
    set have;
    if find(product,'1200')&amp;gt;0 then maturity=intnx('year',reporting_dt,100,'s');
    else maturity=reporting_dt;
    format maturity reporting_dt ddmmyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 01 Dec 2020 17:32:37 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-12-01T17:32:37Z</dc:date>
    <item>
      <title>Conditional that evaluates two variables to create a new one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702840#M25956</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am again having trouble with what seems to be a fairly simple task but I am not able to execute it.&lt;/P&gt;&lt;P&gt;In my dataset I have a variable that contains product names. These products can be of different types (let's say 0 and 1200) and depending on the type, they have a different maturity. If they are of type 0, the maturity is equal to the reporting date (that I have available, it's always the same value) and if they are of type 1200, the maturity is equal to the reporting date plus 100 years (I have created this other variable in a data step, it's maturity_1200 in the code that I attach).&lt;/P&gt;&lt;P&gt;My desired output dataset must have the product names, reporting date and maturity date, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;REPORTING_DT&amp;nbsp; &amp;nbsp; &amp;nbsp;PRODUCT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MATURITY&lt;/P&gt;&lt;P&gt;31/03/2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bonds_0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31/03/2018&lt;/P&gt;&lt;P&gt;31/03/2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bonds_1200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31/03/2118&lt;/P&gt;&lt;P&gt;31/03/2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;savings_0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/03/2018&lt;/P&gt;&lt;P&gt;31/03/2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;savings_1200&amp;nbsp; &amp;nbsp; &amp;nbsp; 31/03/2118&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the code that I attach, but it doesn't work. I have tried to find syntax mistakes but the log is just not returning any errors and I get no output. It just doesn't run. I have also tried adding maturity as an empty variable and then updating (it has worked in the past) but again, it doesn't work.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.step3;
   set work.step3;
   maturity=ifn(product like '%_1200', maturity_1200, reporting_dt);
   FORMAT maturity DDMMYY10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you so much for your time and help&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 17:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702840#M25956</guid>
      <dc:creator>mariapf</dc:creator>
      <dc:date>2020-12-01T17:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional that evaluates two variables to create a new one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702843#M25957</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input REPORTING_DT   ddmmyy10.  PRODUCT     $12.  ;
cards;
31/03/2018 bonds_0      
31/03/2018 bonds_1200   
31/03/2018 savings_0    
31/03/2018 savings_1200 
;
data want;
    set have;
    if find(product,'1200')&amp;gt;0 then maturity=intnx('year',reporting_dt,100,'s');
    else maturity=reporting_dt;
    format maturity reporting_dt ddmmyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Dec 2020 17:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702843#M25957</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-01T17:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional that evaluates two variables to create a new one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702844#M25958</link>
      <description>LIKE doesn't work in a data step. The log should be generating errors and it's helpful if you include those. Try using INDEX or FIND instead of Like. Or a standard IF statement would always work, rather than IFN. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Dec 2020 17:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702844#M25958</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-01T17:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional that evaluates two variables to create a new one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702860#M25959</link>
      <description>&lt;P&gt;Use of the same data set as input and output as in&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data work.step3;
   set work.step3;
   maturity=ifn(product like '%_1200', maturity_1200, reporting_dt);
   FORMAT maturity DDMMYY10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;completely replaces the data set. So a previous step may have had your data set work.step3 have not observations or done something else that causes the log not to show errors this time but if you had a logic error you are stuck with previous results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While learning coding you really want to create a new output data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2020 18:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/702860#M25959</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-01T18:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional that evaluates two variables to create a new one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/703019#M25970</link>
      <description>&lt;P&gt;Hi, thank you for your response and thank you for your advice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried creating&amp;nbsp; a new dataset and checking my previous one but the problem still remained.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 08:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/703019#M25970</guid>
      <dc:creator>mariapf</dc:creator>
      <dc:date>2020-12-02T08:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional that evaluates two variables to create a new one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/703022#M25971</link>
      <description>&lt;P&gt;Hi Paige, this worked great and I'm sure it will help me a lot with future tasks. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 08:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-that-evaluates-two-variables-to-create-a-new-one/m-p/703022#M25971</guid>
      <dc:creator>mariapf</dc:creator>
      <dc:date>2020-12-02T08:37:13Z</dc:date>
    </item>
  </channel>
</rss>

