Previous Page | Next Page

Retrieving Data from a Single Table

Validating a Query

The VALIDATE statement enables you to check the syntax of a query for correctness without submitting it to PROC SQL. PROC SQL displays a message in the log to indicate whether the syntax is correct.

proc sql;
   validate
      select Name, Statehood
         from sql.unitedstates
         where Statehood lt '01Jan1800'd;

Validating a Query (Partial Log)

3  proc sql;
4     validate
5        select Name, Statehood
6           from sql.unitedstates
7           where Statehood lt '01Jan1800'd;
NOTE: PROC SQL statement has valid syntax.

The following example shows an invalid query and the corresponding log message:

proc sql;
   validate
      select Name, Statehood
      from sql.unitedstates
      where lt '01Jan1800'd;

Validating an Invalid Query (Partial Log)

3  proc sql;
4     validate
5        select Name, Statehood
6        from sql.unitedstates
7        where lt '01Jan1800'd;
                    ------------
                    22
                    76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, 
              +, -, /, <, <=, <>, =, >, >=, ?, AND, CONTAINS, EQ, GE, GROUP, 
              GT, HAVING, LE, LIKE, LT, NE, OR, ORDER, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The SAS System stopped processing this step because of errors.

Previous Page | Next Page | Top of Page