<?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: How to identify an extra semicolon in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92474#M289917</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate your point, but I disagree with you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A &amp;lt; B THEN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is a perfectly valid statement. It means don't do anything if A is less than B. Of course, for it to be useful it would have to be followed by an ELSE, as in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A &amp;lt; B THEN; ELSE COMMENT = "A is not less than B";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which of course is equivalent to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A &amp;gt;= B THEN; ELSE COMMENT = "A is not less than B";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and it's a sensible response to say that the latter should always be used. However, there are a couple of circumstances where these "no-op" statements occur:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fairly often, one ends up in a nested set of IF statements, such as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A = 1&lt;/P&gt;&lt;P&gt;THEN IF B = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; THEN X = 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE;&lt;/P&gt;&lt;P&gt;ELSE X = 6:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where the ELSE; is required to match ELSE X = 6 with IF A = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another case is where the condition could be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A = 1 THEN X = 5;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;without an ELSE clause, but for reasons of clarity and readability it makes more sense to code the condition as the negation, so it becomes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF /* a condition that makes the most sense stated this way */ THEN;&lt;/P&gt;&lt;P&gt;ELSE /* some actions */;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it sounds weird, but I've done it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My $.02 worth!&lt;/P&gt;&lt;P&gt;&amp;nbsp; Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 01 Jun 2013 19:18:11 GMT</pubDate>
    <dc:creator>TomKari</dc:creator>
    <dc:date>2013-06-01T19:18:11Z</dc:date>
    <item>
      <title>How to identify an extra semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92470#M289913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If I write&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF A &amp;lt; B then;&amp;nbsp;&amp;nbsp; B= A;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc.&amp;nbsp;&amp;nbsp;&amp;nbsp; B will always be given the value of A - because there is a semicolon directly after THEN.&lt;/P&gt;&lt;P&gt;In other words - SAS does not give any protest or WARNING when the THEN Clause is empty!&lt;/P&gt;&lt;P&gt;My Question: Is there any good way of identifying this problem ?&lt;/P&gt;&lt;P&gt;(except using the Editor and look for&amp;nbsp;&amp;nbsp; the strings&amp;nbsp; "THEN;"&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; "THEN ;" )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Br Anders&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jun 2013 16:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92470#M289913</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2013-06-01T16:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify an extra semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92471#M289914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A lot of SAS programmers adopt a programming style of only one statement per line.&amp;nbsp; So then seeing more than one semi-colon on the same line would be a warning that there might be an issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jun 2013 17:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92471#M289914</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-06-01T17:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify an extra semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92472#M289915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! I do agree with Tom, but:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; IF A &amp;lt; B THEN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; B= A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- only one semicolon . Still no warning from SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been using SAS for many years. I have never made this mistake before, until yesterday.&lt;/P&gt;&lt;P&gt;In my 'program' this a statement that can be taken away.&lt;/P&gt;&lt;P&gt;I think that this is a bug in SAS. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jun 2013 17:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92472#M289915</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2013-06-01T17:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify an extra semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92473#M289916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;BR /&gt;I tried the same problem in SAS MACRO:&lt;/P&gt;&lt;P&gt;%MACRO TEST(A);&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %IF &amp;amp;A=2 %THEN %PUT OK&amp;amp;A;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%MEND TEST;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%TEST(2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MACRO TESTTHEN(A);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %IF &amp;amp;A=3 %THEN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT OK&amp;amp;A;&lt;/P&gt;&lt;P&gt;%MEND TESTTHEN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%TESTTHEN(3);&lt;/P&gt;&lt;P&gt;I think that this is a bug in SAS Macro.&lt;/P&gt;&lt;P&gt;Question:&amp;nbsp;&amp;nbsp; Are there any good ways to identify an extra semicolon ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jun 2013 18:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92473#M289916</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2013-06-01T18:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify an extra semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92474#M289917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate your point, but I disagree with you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A &amp;lt; B THEN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is a perfectly valid statement. It means don't do anything if A is less than B. Of course, for it to be useful it would have to be followed by an ELSE, as in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A &amp;lt; B THEN; ELSE COMMENT = "A is not less than B";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which of course is equivalent to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A &amp;gt;= B THEN; ELSE COMMENT = "A is not less than B";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and it's a sensible response to say that the latter should always be used. However, there are a couple of circumstances where these "no-op" statements occur:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fairly often, one ends up in a nested set of IF statements, such as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A = 1&lt;/P&gt;&lt;P&gt;THEN IF B = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; THEN X = 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE;&lt;/P&gt;&lt;P&gt;ELSE X = 6:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where the ELSE; is required to match ELSE X = 6 with IF A = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another case is where the condition could be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A = 1 THEN X = 5;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;without an ELSE clause, but for reasons of clarity and readability it makes more sense to code the condition as the negation, so it becomes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF /* a condition that makes the most sense stated this way */ THEN;&lt;/P&gt;&lt;P&gt;ELSE /* some actions */;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it sounds weird, but I've done it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My $.02 worth!&lt;/P&gt;&lt;P&gt;&amp;nbsp; Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Jun 2013 19:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-an-extra-semicolon/m-p/92474#M289917</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2013-06-01T19:18:11Z</dc:date>
    </item>
  </channel>
</rss>

