<?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 Dates error message ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;&amp;amp; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973154#M377651</link>
    <description>&lt;P&gt;The character that is underlined is right paren ).&amp;nbsp; SAS is listing all the things that it "allows" in the context and )&amp;nbsp; is not in the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the ) right paren and see what you get.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Aug 2025 20:55:12 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2025-08-22T20:55:12Z</dc:date>
    <item>
      <title>SAS Dates error message ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;, *, **,</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973151#M377650</link>
      <description>&lt;P&gt;Hi, I am looking at the SAS CSV USA-TSA Claim Data and I am getting this error: I am asked to create a column called&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Date_Issues&lt;/FONT&gt; where I track if there is an incorrect or unexpected formatting of the dates. It says that I should flag the date issues if either of the two date columns, &lt;FONT face="courier new, courier"&gt;Incident_Date&lt;/FONT&gt;&amp;nbsp;or &lt;FONT face="courier new,courier"&gt;Date_Received&lt;/FONT&gt;, are outside the date range 2002-2017, or if &lt;FONT face="courier new,courier"&gt;Incident_Date&amp;gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;Date_Received&lt;/FONT&gt;. However, I am getting this error message when I do the inequality test:&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE class=""&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         data work.tsa_adjust;
 70             set work.tsa_claims;
 71             format Date_Received Incident_Date date9.;
 72             length Claim_Site Claim_Type Disposition $ 100;
 WARNING: Length of character variable Claim_Site has already been set. 
          Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
 WARNING: Length of character variable Claim_Type has already been set. 
          Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
 WARNING: Length of character variable Disposition has already been set. 
          Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
 73             if (Claim_Site in('-' '') or Claim_Site=.) then Claim_Site='Unknown';
 74             if (Disposition in('-' '') or Disposition=.) then Disposition='Unknown';
 75             if (Claim_Type in('-' '') or Claim_Type=.) then Claim_Type='Unknown';
 76             if (Incident_Date=.) or (Incident_Date&amp;lt;'01JAN2002'd or Incident_Date&amp;gt;'31DEC2017'd))
                                                                                                  _
                                                                                                  22
                                                                                                  200
 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, 
               IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, ~=.  
 
 ERROR 200-322: The symbol is not recognized and will be ignored.
 
 77             then Date_Issues='Needs Review';
 78             if (Date_Received=.) or (Date_Received&amp;lt;'01JAN2002'd or Date_Received&amp;gt;'31DEC2017'd))
                                                                                                  _
                                                                                                  22
                                                                                                  200
 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, 
               IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, ~=.  
 
 ERROR 200-322: The symbol is not recognized and will be ignored.
 
 79             then Date_Issues='Needs Review';
 80         if (Incident_Date&amp;gt;Date_Received) then Date_Issues='Needs Review';&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 22 Aug 2025 20:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973151#M377650</guid>
      <dc:creator>rajueric</dc:creator>
      <dc:date>2025-08-22T20:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates error message ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;&amp;</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973154#M377651</link>
      <description>&lt;P&gt;The character that is underlined is right paren ).&amp;nbsp; SAS is listing all the things that it "allows" in the context and )&amp;nbsp; is not in the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the ) right paren and see what you get.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2025 20:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973154#M377651</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-08-22T20:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates error message ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;&amp;</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973159#M377653</link>
      <description>Count opening vs. closing brackets in the incriminated statement.</description>
      <pubDate>Sat, 23 Aug 2025 06:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973159#M377653</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-23T06:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates error message ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;&amp;</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973160#M377654</link>
      <description>PS in SAS, the condition in an IF does not need to be enclosed in brackets, as the IF and THEN keywords already do this.</description>
      <pubDate>Sat, 23 Aug 2025 06:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973160#M377654</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-23T06:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates error message ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;&amp;</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973179#M377658</link>
      <description>&lt;P&gt;It should be flagging the extra ) in the statement and not the date literal.&lt;/P&gt;
&lt;PRE&gt;46   data _null_;
47    if (Incident_Date=.) or (Incident_Date&amp;lt;'01JAN2002'd or Incident_Date&amp;gt;'31DEC2017'd))
                                                                                        -
                                                                                        22
                                                                                        200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;,
              =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN,
              ^, ^=, |, ||, ~, ~=.

ERROR 200-322: The symbol is not recognized and will be ignored.

48    then Date_Issues='Needs Review';
49   run;
&lt;/PRE&gt;
&lt;P&gt;But I was able to get SAS into a state where it did flag the date literal as an error.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;825  data _null_;
826     if (Incident_Date=.) or (Incident_Date&amp;lt;'01JAN2002'd or Incident_Date&amp;gt;'31DEC2017'd))
                                               -
                                               390
                                               200
                                               76
ERROR 390-185: Expecting an relational or arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

827       then Date_Issues='Needs Review';
828  run;
&lt;/PRE&gt;
&lt;P&gt;Not sure if it was because of some hidden character I copied from your example code or some other previous syntax errors I had made in the same SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;But starting a new SAS session got it back to normal behavior.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2025 00:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Dates-error-message-ERROR-22-322-Syntax-error-expecting-one/m-p/973179#M377658</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-25T00:44:28Z</dc:date>
    </item>
  </channel>
</rss>

