As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
SQL procedure
Within SAS, the SQL procedure is used to run SQL queries on data set(s) or database(s). The differences between PROC SQL and the DATA Step and advantages of each have been discussed in various papers; see PROC SQL vs. DATA Step.
Contents
Using PROC SQL
proc sql <options>; <SQL statement(s)> quit;
Multiple SQL queries may be run from the same PROC SQL step.
There are many uses of the SQL procedure, including creating, modifying,[1] and joining data sets. To delve into some of the examples of what you can do, see the pages in the SQL Procedure category.
PROC SQL options
Optional <options> that may be passed at the beginning of a PROC SQL step include inobs= and outobs= to limit the number of observations read in or output, NOPRINT to suppress printing results in a report, respectively, and feedback to write more information to the log, method to change how PROC SQL operates. A more comprehensive list is available here.
Further reading
Introductory papers and articles
- Introduction to Proc SQL
- 268-29: Introduction to PROC SQL
- An Introduction to SAS® PROC SQL
- Proc SQL - Double the Syntax, Double the Fun
SAS Documentation and publications
- SAS SQL Procedure documentation and SAS SQL Procedure User's Guides: 9.1, 9.4
- SAS documentation: PROC SQL options
Books
- The book PROC SQL by Example has code samples available for download.
- PROC SQL: Beyond the Basics Using SAS, Second Edition
- PROC SQL: Beyond the Basics Using SAS by Kirk Paul Lafler
- Quick Results with Proc SQL
Wiki articles on specific topics
- Advanced SQL Processing
- Count Four Different Ways with SQL
- CREATE statement (SQL) can generate only one output
- How to Use Proc SQL select into for List Processing
- Inserting a Blank Row into Output with PROC SQL
- PROC SQL OPERATORS AND FUNCTIONS
- Proc SQL vs. Pass-Thru SQL on DB2®: Or How I Found a Day
- SQL Allows Multiple Columns with Same Name
- SQL UNION operator
- SQL automatic macro variables are reinitialized after each SQL statement
- Using SAS Views and SQL Views
- Using SQL to transpose vertical to horizontal
- Variable List Short-Cuts in PROC SQL
- Anatomy of a SQL query
- Random Sample using Proc SQL
- PL SQL in SAS passthrough connect to oracle
- Proc SQL as Proc Contents
- Phonetic Matching (Sounds-Like Operator =*) in PROC SQL
- Pass Through Queries