<?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: If statement problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435761#M282053</link>
    <description>I'm sorry it works now. The problem was in THEN statement, i had the incorrect column name. I apologize for silly mistake. Thank you Reeza.</description>
    <pubDate>Fri, 09 Feb 2018 18:13:54 GMT</pubDate>
    <dc:creator>arunsunny</dc:creator>
    <dc:date>2018-02-09T18:13:54Z</dc:date>
    <item>
      <title>If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435717#M282046</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use an IF statement to create output for column H using the logic I have written below. There would be a dynamic calculation while executing the IF statement. Please let me know if this can work dynamically &amp;amp; want a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NEW_GRP Logic for 1 set (i.e. Cash &amp;amp; vol set) - Refer Excel file attached. I have multiple records in my data set and the following condition would apply for all records.&lt;BR /&gt;&lt;BR /&gt;IF CAT = 'CASH' AND VOL = 'Small' AND (KPI &amp;lt;= MEAN) THEN NEW_GRP = 'NIL'&lt;BR /&gt;IF CAT = 'CASH' AND VOL = 'Medium' AND (KPI &amp;gt; MEAN and KPI &amp;lt; SD1) THEN NEW_GRP = 'Low'&lt;BR /&gt;IF CAT = 'CASH' AND VOL = 'Medium' AND (KPI &amp;gt; SD1 and KPI &amp;lt; SD2) THEN NEW_GRP = 'High'&lt;BR /&gt;IF CAT = 'CASH' AND VOL = 'Medium' AND (KPI &amp;gt;= SD2) THEN NEW_GRP = 'Very High'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently use SAS EG 7.1 64 bit (SAS 9.4 built in).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435717#M282046</guid>
      <dc:creator>arunsunny</dc:creator>
      <dc:date>2018-02-09T17:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435718#M282047</link>
      <description>&lt;P&gt;It's not clear what's 'dynamic' about your IF statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are they not working? I'm not sure what your question is here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: you should also use IF/ELSE IF rather than multiple IF statements. Especially if it's possible to have multiple IF statements be true.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192461"&gt;@arunsunny&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use an IF statement to create output for column H using the logic I have written below. There would be a dynamic calculation while executing the IF statement. Please let me know if this can work dynamically &amp;amp; want a solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NEW_GRP Logic for 1 set (i.e. Cash &amp;amp; vol set) - Refer Excel file attached. I have multiple records in my data set and the following condition would apply for all records.&lt;BR /&gt;&lt;BR /&gt;IF CAT = 'CASH' AND VOL = 'Small' AND (KPI &amp;lt;= MEAN) THEN NEW_GRP = 'NIL'&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ELSE&lt;/FONT&gt; &lt;/STRONG&gt;IF CAT = 'CASH' AND VOL = 'Medium' AND (KPI &amp;gt; MEAN and KPI &amp;lt; SD1) THEN NEW_GRP = 'Low'&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;ELSE&lt;/STRONG&gt;&lt;/FONT&gt; IF CAT = 'CASH' AND VOL = 'Medium' AND (KPI &amp;gt; SD1 and KPI &amp;lt; SD2) THEN NEW_GRP = 'High'&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ELSE&lt;/FONT&gt;&lt;/STRONG&gt; IF CAT = 'CASH' AND VOL = 'Medium' AND (KPI &amp;gt;= SD2) THEN NEW_GRP = 'Very High'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Arun&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435718#M282047</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-09T17:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435727#M282048</link>
      <description>&lt;P&gt;To provide more clarity, i need the output in column H to be this:&lt;/P&gt;&lt;P&gt;=IF(C2&amp;lt;=D2,"Nil",IF(AND(C2&amp;gt;E2,C2&amp;lt;=F2),"Low", IF(AND(C2&amp;gt;E2,C2&amp;lt;=F2),"High","Very High")))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i can do this in excel with formula above, but i want to use the same logic in SAS using IF statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435727#M282048</guid>
      <dc:creator>arunsunny</dc:creator>
      <dc:date>2018-02-09T17:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435730#M282049</link>
      <description>&lt;P&gt;Your IF statements are correct, did you try it and not have it work?&lt;/P&gt;
&lt;P&gt;I still don't understand what you're asking for here, ie what kind of answer are you looking for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192461"&gt;@arunsunny&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;To provide more clarity, i need the output in column H to be this:&lt;/P&gt;
&lt;P&gt;=IF(C2&amp;lt;=D2,"Nil",IF(AND(C2&amp;gt;E2,C2&amp;lt;=F2),"Low", IF(AND(C2&amp;gt;E2,C2&amp;lt;=F2),"High","Very High")))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i can do this in excel with formula above, but i want to use the same logic in SAS using IF statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Arun&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435730#M282049</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-09T17:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435742#M282050</link>
      <description>&lt;P&gt;The columns C to G have values and when you reference this in excel, i get result. In SAS i get blank data. If I hard code the values i get a result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Logic with values hard coded for columns C to G - Works well in SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF CAT = 'CASH' AND VOL = 'Small' AND KPI &amp;lt;= 0.00177 THEN NEW_GRP = 'NIL'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; 0.00177 and KPI &amp;lt; 0.00578 THEN NEW_GRP = 'Low'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; 0.00578 and KPI &amp;lt; 0.01379 THEN NEW_GRP = 'High'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt;= 0.01379 THEN NEW_GRP = 'Very High'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesnt work in SAS:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF CAT = 'CASH' AND VOL = 'Small' AND KPI &amp;lt;= MEAN THEN NEW_GRP = 'NIL'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; MEAN and KPI &amp;lt; SD1 THEN NEW_GRP = 'Low'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; SD1 and KPI &amp;lt; SD2 THEN NEW_GRP = 'High'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt;= SD2 THEN NEW_GRP = 'Very High'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is it take lot of time to hard code multiple values (columns C to G) for multiple sets within the logic. Hope this is clear now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435742#M282050</guid>
      <dc:creator>arunsunny</dc:creator>
      <dc:date>2018-02-09T17:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435755#M282051</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;This doesnt work in SAS:&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does "this doesn't work" mean "You get blank values"?&lt;/P&gt;
&lt;P&gt;What does the log show? Can you provide sample data as text so we can run your code?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is fine, if its not working you likely are referencing your variables incorrectly. The log will usually indicate this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192461"&gt;@arunsunny&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The columns C to G have values and when you reference this in excel, i get result. In SAS i get blank data. If I hard code the values i get a result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Logic with values hard coded for columns C to G - Works well in SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF CAT = 'CASH' AND VOL = 'Small' AND KPI &amp;lt;= 0.00177 THEN NEW_GRP = 'NIL'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; 0.00177 and KPI &amp;lt; 0.00578 THEN NEW_GRP = 'Low'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; 0.00578 and KPI &amp;lt; 0.01379 THEN NEW_GRP = 'High'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt;= 0.01379 THEN NEW_GRP = 'Very High'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesnt work in SAS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF CAT = 'CASH' AND VOL = 'Small' AND KPI &amp;lt;= MEAN THEN NEW_GRP = 'NIL'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; MEAN and KPI &amp;lt; SD1 THEN NEW_GRP = 'Low'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt; SD1 and KPI &amp;lt; SD2 THEN NEW_GRP = 'High'&lt;BR /&gt;ELSE IF CAT = 'CASH' AND VOL = 'Medium' AND KPI &amp;gt;= SD2 THEN NEW_GRP = 'Very High'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is it take lot of time to hard code multiple values (columns C to G) for multiple sets within the logic. Hope this is clear now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435755#M282051</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-09T18:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435758#M282052</link>
      <description>Does "this doesn't work" mean "You get blank values"? - YES&lt;BR /&gt;&lt;BR /&gt;What does the log show? Can you provide sample data as text so we can run your code? - You can use the attached excel in my 1st post to see data &amp;amp; logic.&lt;BR /&gt;&lt;BR /&gt;SAS Log:&lt;BR /&gt;NOTE: Variable NEW_GRP is uninitialized.</description>
      <pubDate>Fri, 09 Feb 2018 18:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435758#M282052</guid>
      <dc:creator>arunsunny</dc:creator>
      <dc:date>2018-02-09T18:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435761#M282053</link>
      <description>I'm sorry it works now. The problem was in THEN statement, i had the incorrect column name. I apologize for silly mistake. Thank you Reeza.</description>
      <pubDate>Fri, 09 Feb 2018 18:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435761#M282053</guid>
      <dc:creator>arunsunny</dc:creator>
      <dc:date>2018-02-09T18:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: If statement problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435762#M282054</link>
      <description>&lt;P&gt;Are you using the code you posted as is? You are missing semicolons at the end of every statement which is probably why SAS is complaining about uninitialized variables.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-problem/m-p/435762#M282054</guid>
      <dc:creator>antonbcristina</dc:creator>
      <dc:date>2018-02-09T18:13:56Z</dc:date>
    </item>
  </channel>
</rss>

