<?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: syntax error in IF condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626730#M184881</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want;
	set text;
	if Result_t ^= '' and Source__Type_ in ('Nasopharyngeal swab', 'Throat (Oropharyngeal) swab');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 23 Feb 2020 17:06:43 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-02-23T17:06:43Z</dc:date>
    <item>
      <title>syntax error in IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626729#M184880</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An error massage is shown in my coding.&amp;nbsp;&amp;nbsp; Please correct, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;198 DATA Text;&lt;/P&gt;
&lt;P&gt;199 set Text;&lt;/P&gt;
&lt;P&gt;200 IF&amp;nbsp;result ^= '' and Source__Type in ('Nasopharyngeal swab' or 'Throat&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---&lt;/P&gt;
&lt;P&gt;79&lt;/P&gt;
&lt;P&gt;388&lt;/P&gt;
&lt;P&gt;200&lt;/P&gt;
&lt;P&gt;76&lt;/P&gt;
&lt;P&gt;200! (Oropharyngeal) swab' or 'Oral swab');&lt;/P&gt;
&lt;P&gt;ERROR 79-322: Expecting a ).&lt;/P&gt;
&lt;P&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;201 run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA want;
	set text;
	if Result_t ^= '' and Source__Type_ in ('Nasopharyngeal swab' or 'Throat (Oropharyngeal) swab');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 17:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626729#M184880</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-02-23T17:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: syntax error in IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626730#M184881</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want;
	set text;
	if Result_t ^= '' and Source__Type_ in ('Nasopharyngeal swab', 'Throat (Oropharyngeal) swab');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Feb 2020 17:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626730#M184881</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-23T17:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: syntax error in IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626734#M184882</link>
      <description>&lt;P&gt;Can't believe that forgot the comma!&lt;img id="womanembarrassed" class="emoticon emoticon-womanembarrassed" src="https://communities.sas.com/i/smilies/16x16_woman-embarrassed.png" alt="Woman Embarassed" title="Woman Embarassed" /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 17:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626734#M184882</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-02-23T17:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: syntax error in IF condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626735#M184883</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can't believe that forgot the comma!&lt;img id="womanembarrassed" class="emoticon emoticon-womanembarrassed" src="https://communities.sas.com/i/smilies/16x16_woman-embarrassed.png" alt="Woman Embarassed" title="Woman Embarassed" /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS does NOT need a comma between the items listed when using the IN operator.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class;
  where age in (11 12)
    or name in ('Alfred' 'Alice')
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your problem is that you gave the IN operator a variable name when it wanted a list of character values.&lt;/P&gt;
&lt;PRE&gt;2991  proc print data=sashelp.class;
2992    where age in (11 12)
2993      or name in ('Alfred' or 'Alice')
                               --
                               22
                               202
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ), ','.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
2994    ;
ERROR: Syntax error while parsing WHERE clause.
2995  run;

3001  proc print data=sashelp.class;
3002    where age in (11 12)
3003      or name in ('Alfred' 123 'Alice')
                               ---
                               22
                               200
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ), ','.
ERROR 200-322: The symbol is not recognized and will be ignored.
3004    ;
ERROR: Syntax error while parsing WHERE clause.
3005  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


3006  proc print data=sashelp.class;
3007    where age in (11 12)
3008      or name in ('Alfred' age 'Alice')
                               ---
                               22
                               202
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ), ','.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
3009    ;
ERROR: Syntax error while parsing WHERE clause.
3010  run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 17:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/syntax-error-in-IF-condition/m-p/626735#M184883</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-23T17:51:17Z</dc:date>
    </item>
  </channel>
</rss>

