SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Performing Queries Using SQL
PROC SQL Basics


How PROC SQL Is Unique

PROC SQL differs from most other SAS procedures in several ways:

  • Unlike other PROC steps, PROC SQL is made up of statements and clauses. Here is an example of a PROC SQL step. Notice that the SELECT statement contains several clauses (FROM, WHERE, and ORDER BY, for example).

          proc sql;
             select id,lastname,netpay,grosspay,
                    grosspay*.06 as bonus
                from emplib.payroll
                where netpay>25000
                order by lastname;

  • Notice also that the PROC SQL step does not require a RUN statement. PROC SQL executes each query automatically. If you follow a PROC SQL step with a RUN statement, SAS software ignores the RUN statement, submits the statements as usual, and generates the following log message:
Note: PROC SQL statements are executed immediately.  The RUN statement has no effect.

  • When you submit the PROC SQL step, the status line in the Program Editor window displays the message PROC SQL running. Unlike most other procedures, the SQL procedure continues to run after you submit a step.

Program Editor window with message


To end the procedure, you can submit another PROC step, a DATA step, or a QUIT statement (shown below).
          quit;
back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement