<?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 if else not working when using parentheses in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144663#M1420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS interprets that as else() which looks like an array. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use indenting to help with code understanding. &lt;/P&gt;&lt;P&gt;Addtionally for recoding you could use either a SELECT statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jan 2015 20:35:57 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-01-29T20:35:57Z</dc:date>
    <item>
      <title>sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144662#M1419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why is this code giving error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data test;&lt;/P&gt;&lt;P&gt;length a: $5;&lt;BR /&gt;a='2';&lt;BR /&gt;if a = '1' then&amp;nbsp; a ='a' ;&lt;BR /&gt;else (&lt;BR /&gt; a= 'b'); &lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: Undeclared array referenced: else.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I realise removing the parentheses will solve the issue, but i want to keep the parentheses for ease of understanding. Ultimately the else box will have many if else if conditions and the parentheses helps greatly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 12pt; font-family: Courier New;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144662#M1419</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2015-01-29T20:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144663#M1420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS interprets that as else() which looks like an array. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use indenting to help with code understanding. &lt;/P&gt;&lt;P&gt;Addtionally for recoding you could use either a SELECT statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144663#M1420</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-29T20:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144664#M1421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thanks. Can you show with example what you mean by recoding with SELECT statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144664#M1421</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2015-01-29T20:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144665#M1422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From the docs:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201966.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201966.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select (a);&lt;/P&gt;&lt;P&gt;&amp;nbsp; when (1) x=x*10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; when (2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; when (3,4,5) x=x*100;&lt;/P&gt;&lt;P&gt;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS. Personally I actually prefer proc format for recoding - my go to reference paper for that is "Proc Format: Not just another pretty face"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144665#M1422</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-29T20:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144666#M1423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't use parentheses here. To format your code for better readability, use comments, indentation etc. For example here if you really want to group the part after 'else', try insert some comments where you tried parentheses, such as /**/.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you do else (), SAS compiler will take 'else' as an array name, like indicated by the error message. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144666#M1423</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-29T20:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144667#M1424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This would have worked to reassign the value for A.&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;length a: $5;&lt;BR /&gt;a='2';&lt;BR /&gt;if a = '1' then&amp;nbsp; a ='a' ;&lt;BR /&gt;else a= 'b'; &lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also a warning: (a='b') Could be a conditional value in other code locations.&lt;/P&gt;&lt;P&gt;C = (a='b'); will assign a value of 1 (typical value for "true" in SAS) to the variable C when a='b' and 0 when not equal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144667#M1424</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-01-29T20:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else not working when using parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144668#M1425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You do not use () to group statements in SAS.&amp;nbsp; Use DO: ... END; blocks for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A='1' THEN DO;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;END:&lt;/P&gt;&lt;P&gt;ELSE DO;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 03:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/sas-if-else-not-working-when-using-parentheses/m-p/144668#M1425</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-01-30T03:59:20Z</dc:date>
    </item>
  </channel>
</rss>

