<?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 PROC SQL Syntax Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755476#M238405</link>
    <description>&lt;P&gt;Why am I getting a syntax error? It looks like it wants me to have some sort of symbol, but I already have a comma there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;1058  proc sql noprint;
1059   create table catdem as
1060   /*ETHNICITIES*/
1061      /*NOT HISPANIC OR LATINO - Cohort A*/
1062   select 1 as CAT, 1 as SUBCAT, 'Not Hispanic or Latino' as CHAR,
1063    count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and
1063! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
1063    count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and
1063! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
                                        -
                                        22
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=,
              &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT,
              HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ORDER,
              OUTER, UNION, ^, ^=, |, ||, ~, ~=.

1063    count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and
1063! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
                                        -
                                        76
ERROR 76-322: Syntax error, statement will be ignored.

1064    count(distinct USUBJID) as N_OB from data where ETHNICN = 1 and BMIGRP = 'Obese' and
1064! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
1065    count(distinct USUBJID) as N_SOB from data where ETHNICN = 1 and BMIGRP = 'Severely Obese'
1065!  and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
1066    count(distinct USUBJID) as N from data where ETHNICN = 1 and (ARMCD = 'A' or ARMCD =
1066! 'A_AND_B');
1067  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
 create table catdem as
 /*ETHNICITIES*/
	/*NOT HISPANIC OR LATINO - Cohort A*/
 select 1 as CAT, 1 as SUBCAT, 'Not Hispanic or Latino' as CHAR, 
  count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
  count(distinct USUBJID) as N_OB from data where ETHNICN = 1 and BMIGRP = 'Obese' and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
  count(distinct USUBJID) as N_SOB from data where ETHNICN = 1 and BMIGRP = 'Severely Obese' and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
  count(distinct USUBJID) as N from data where ETHNICN = 1 and (ARMCD = 'A' or ARMCD = 'A_AND_B');
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jul 2021 19:19:57 GMT</pubDate>
    <dc:creator>mariko5797</dc:creator>
    <dc:date>2021-07-20T19:19:57Z</dc:date>
    <item>
      <title>PROC SQL Syntax Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755476#M238405</link>
      <description>&lt;P&gt;Why am I getting a syntax error? It looks like it wants me to have some sort of symbol, but I already have a comma there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;1058  proc sql noprint;
1059   create table catdem as
1060   /*ETHNICITIES*/
1061      /*NOT HISPANIC OR LATINO - Cohort A*/
1062   select 1 as CAT, 1 as SUBCAT, 'Not Hispanic or Latino' as CHAR,
1063    count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and
1063! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
1063    count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and
1063! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
                                        -
                                        22
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=,
              &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT,
              HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ORDER,
              OUTER, UNION, ^, ^=, |, ||, ~, ~=.

1063    count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and
1063! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
                                        -
                                        76
ERROR 76-322: Syntax error, statement will be ignored.

1064    count(distinct USUBJID) as N_OB from data where ETHNICN = 1 and BMIGRP = 'Obese' and
1064! (ARMCD = 'A' or ARMCD = 'A_AND_B'),
1065    count(distinct USUBJID) as N_SOB from data where ETHNICN = 1 and BMIGRP = 'Severely Obese'
1065!  and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
1066    count(distinct USUBJID) as N from data where ETHNICN = 1 and (ARMCD = 'A' or ARMCD =
1066! 'A_AND_B');
1067  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
 create table catdem as
 /*ETHNICITIES*/
	/*NOT HISPANIC OR LATINO - Cohort A*/
 select 1 as CAT, 1 as SUBCAT, 'Not Hispanic or Latino' as CHAR, 
  count(distinct USUBJID) as N_NOB from data where ETHNICN = 1 and BMIGRP = 'Not Obese' and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
  count(distinct USUBJID) as N_OB from data where ETHNICN = 1 and BMIGRP = 'Obese' and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
  count(distinct USUBJID) as N_SOB from data where ETHNICN = 1 and BMIGRP = 'Severely Obese' and (ARMCD = 'A' or ARMCD = 'A_AND_B'),
  count(distinct USUBJID) as N from data where ETHNICN = 1 and (ARMCD = 'A' or ARMCD = 'A_AND_B');
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 19:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755476#M238405</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2021-07-20T19:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Syntax Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755477#M238406</link>
      <description>&lt;P&gt;In the WHERE clause, you do not use commas. You can place valid Boolean expressions in the WHERE clause.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;There are other problems, you can only have one WHERE clause in your PROC SQL main query (and another WHERE in a subquery which you aren't using, so that doesn't apply here)&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 19:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755477#M238406</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-20T19:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Syntax Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755483#M238412</link>
      <description>&lt;P&gt;You can have only one FROM clause in a SELECT. I guess you want to use a subselect there.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 20:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755483#M238412</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-20T20:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Syntax Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755504#M238421</link>
      <description>&lt;P&gt;You can't just invent syntax as you go. This is invalid SQL.&lt;/P&gt;
&lt;P&gt;Maybe use something like this to get you started.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;                                
  create table TMP as 
  select BMIGRP
       , count(distinct USUBJID) as N 
  where ETHNICN = 1 
    and ARMCD in ('A', 'A_AND_B')
  group by BMIGRP;

  create table CATDEM as
  select 1                                 as CAT
       , 1                                 as SUBCAT
       , 'Not Hispanic or Latino'          as CHAR
       , sum(N*(BMIGRP='Not Obese'))       as N1
       , sum(N*(BMIGRP='Obese'    ))       as N2
       , sum(N*(BMIGRP='Severely  Obese')) as N3
  from TMP ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 23:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Syntax-Error/m-p/755504#M238421</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-20T23:30:12Z</dc:date>
    </item>
  </channel>
</rss>

