title: issue with nested select statements in proc sql
body: <p>I was given this code to run but I keep getting errors even after I've made sure there are the right number of left/right brackets.  This is the original code as my adding of brackets seemed to be in the wrong place.</p>
  
  <pre><code>   proc sql;
      create table all as
      select distinct a.id, a.count, b.date
      from (select distinct id, count (*) as count from (select distinct id, p_id, date2 from table1) group by id) a
  (select distinct id, min(date2) as date format datetime. from table1) b
  where a.id=b.id;
  quit;
  
  
  
  (select distinct id, min(date2) as date format datetime. from
                    --------              -
                    22                    22
                    202                   76
  3520! table1) group by id) b
  ERROR 22-322: Syntax error, expecting one of the following: ), ','.
  
  ERROR 202-322: The option or parameter is not recognized and will be ignored.
  
  ERROR 76-322: Syntax error, statement will be ignored.
  </code></pre>
  
  <p>Edit: after adding a comma I then get this error:</p>
  
  <pre><code>256     , (select id, min(date2) as date format datetime. from
  256! table1) group by id ) b
                                     -
                                     22
                                     76
  ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;, (, *, **, +, ',', -,
                '.', /, &lt;, &lt;=, &lt;&gt;, =, &gt;, &gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, EXCEPT, GE, GET,
                GT, GTT, HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN,
                OR, ORDER, OUTER, UNION, ^, ^=, |, ||, ~, ~=.
  
  ERROR 76-322: Syntax error, statement will be ignored.
  
  257    Where a.id=b.id;
  258  quit;
  </code></pre>