<?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: Case when for if clause in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496908#M15486</link>
    <description>&lt;P&gt;Just going by the if statments, something like this should work:&lt;/P&gt;
&lt;PRE&gt;case when renewal_date="19sep" then "19sep2019"d
     when input(cats(renewal_date,"2018"),date9.) &amp;lt; today() then input(cats(renewal_date,"2018"),date9.)
     else input(cats(renewal_date,"2019"),date9.) end &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Its quite hard to tell however, as you use today() in a comparison which will obviously change from day to day, not sure what bearing that has on the code&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2018 11:48:48 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-09-19T11:48:48Z</dc:date>
    <item>
      <title>Case when for if clause</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496902#M15485</link>
      <description>&lt;P&gt;Could you please guide me with the 'case when....' statement or other equivalents in order to align in expression in DI Studio for the following if clauses? I was advised not to use user written transformation. Objective is to create a new variable 'PODVER'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input renewal_date $ KNKATD;
datalines;
15jun 1
21sep 2
19sep 7
08jan 7
;
run;

data want (drop=current_date);
set have;
current_date=today();
format current_date date9.;
format new_renewal_date date9.;
if (input(cats(renewal_date,"2018"),date9.)&amp;lt;current_date) then new_renewal_date=input(cats(renewal_date,"2019"),date9.);
else new_renewal_date=input(cats(renewal_date,"2018"),date9.);
run;

data want_new;
set want;
format PODVER date9.;
if new_renewal_date='19sep2018'd and KNKATD=7 then PODVER=new_renewal_date+365;
else PODVER=new_renewal_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 11:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496902#M15485</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-19T11:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Case when for if clause</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496908#M15486</link>
      <description>&lt;P&gt;Just going by the if statments, something like this should work:&lt;/P&gt;
&lt;PRE&gt;case when renewal_date="19sep" then "19sep2019"d
     when input(cats(renewal_date,"2018"),date9.) &amp;lt; today() then input(cats(renewal_date,"2018"),date9.)
     else input(cats(renewal_date,"2019"),date9.) end &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Its quite hard to tell however, as you use today() in a comparison which will obviously change from day to day, not sure what bearing that has on the code&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 11:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496908#M15486</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T11:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Case when for if clause</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496939#M15487</link>
      <description>&lt;P&gt;You've not checked the condition for KNKATD=7.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 12:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496939#M15487</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-09-19T12:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Case when for if clause</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496944#M15488</link>
      <description>&lt;P&gt;Add it in then, you can copy paste directly the and.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 12:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Case-when-for-if-clause/m-p/496944#M15488</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T12:57:28Z</dc:date>
    </item>
  </channel>
</rss>

