<?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 ... THEN ... followed by AND in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558500#M155870</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/242844"&gt;@stechafle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Why does the first IF Statement below not produce an Error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;x=0; y=1;&lt;/P&gt;
&lt;P&gt;if x=0 then z=0&lt;BR /&gt;and y=0;&lt;/P&gt;
&lt;P&gt;if x=0&lt;BR /&gt;and y=0 then w=0;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=test;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the intent of the first if is to assign values to both Z and Y the code would be:&lt;/P&gt;
&lt;P&gt;if x= 0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; z=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; y=0;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2019 23:11:20 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-13T23:11:20Z</dc:date>
    <item>
      <title>IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558491#M155865</link>
      <description>&lt;P&gt;Why does the first IF Statement below not produce an Error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;x=0; y=1;&lt;/P&gt;&lt;P&gt;if x=0 then z=0&lt;BR /&gt;and y=0;&lt;/P&gt;&lt;P&gt;if x=0&lt;BR /&gt;and y=0 then w=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print data=test;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 22:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558491#M155865</guid>
      <dc:creator>stechafle</dc:creator>
      <dc:date>2019-05-13T22:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558497#M155868</link>
      <description>&lt;P&gt;With SAS the equal sign can be an asignment or an equality operation. z = ... is and assignment because it occurs at the beginning of the statement, but y=0 is an equality operation. SAS represents logical (boolean) values with zeros and ones, 0 = FALSE, 1 = TRUE. The expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;z=0 and y=0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is computed as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;z = (0 and (y=0))&lt;/P&gt;
&lt;P&gt;z = (0 and (1=0)) /* because y = 1 */&lt;/P&gt;
&lt;P&gt;z = (0 and 0) /* because 1=0 is FALSE */&lt;/P&gt;
&lt;P&gt;z = 0 /* Because FALSE and FALSE is FALSE */&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 22:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558497#M155868</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-05-13T22:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558500#M155870</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/242844"&gt;@stechafle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Why does the first IF Statement below not produce an Error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;x=0; y=1;&lt;/P&gt;
&lt;P&gt;if x=0 then z=0&lt;BR /&gt;and y=0;&lt;/P&gt;
&lt;P&gt;if x=0&lt;BR /&gt;and y=0 then w=0;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=test;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the intent of the first if is to assign values to both Z and Y the code would be:&lt;/P&gt;
&lt;P&gt;if x= 0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; z=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; y=0;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 23:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558500#M155870</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-13T23:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558506#M155871</link>
      <description>&lt;P&gt;What error should it produce?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the compiler cannot read your mind to know whether it is what you intended or not.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 23:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558506#M155871</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-13T23:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558507#M155872</link>
      <description>&lt;P&gt;think about it,&lt;/P&gt;
&lt;P&gt;draw pictures with lines results.&lt;/P&gt;
&lt;P&gt;then ask yourself do we give order in that manner?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;no we give clear and understandable orders so a computer understands what the hay you are thinking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 00:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558507#M155872</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-14T00:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558575#M155907</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x=0 then z=0
and y=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;translates to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (x = 0) then z = (0 and (y = 0));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;(0 and (y = 0)) is a valid numeric expression,&amp;nbsp;&lt;/CODE&gt;and once you look at that, you can see that z will always be set to zero if the condition "x equals zero" is met.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 10:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/558575#M155907</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-14T10:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: IF ... THEN ... followed by AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/559387#M156188</link>
      <description>&lt;P&gt;Thank you Kurt! Your explanation makes perfect sense.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 16:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-followed-by-AND/m-p/559387#M156188</guid>
      <dc:creator>stechafle</dc:creator>
      <dc:date>2019-05-16T16:06:56Z</dc:date>
    </item>
  </channel>
</rss>

