0% found this document useful (0 votes)
30 views

Module Summary: Using SQL in SAS

This document provides an overview of using SQL in SAS. It discusses the basic SELECT, FROM, WHERE, and ORDER BY clauses as well as joining tables and creating output tables. PROC SQL creates a report by default and ends with a QUIT statement.

Uploaded by

jefin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Module Summary: Using SQL in SAS

This document provides an overview of using SQL in SAS. It discusses the basic SELECT, FROM, WHERE, and ORDER BY clauses as well as joining tables and creating output tables. PROC SQL creates a report by default and ends with a QUIT statement.

Uploaded by

jefin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Module Summary: Using SQL in SAS

Using Structured Query Language (SQL) in SAS

PROC SQL creates a report by default.

The SELECT statement describes the query. List columns to include in the results after SELECT, separated by
commas.

The FROM clause lists the input table(s).

The ORDER BY clause arranges rows based on the columns listed. The default order is ascending. Use DESC
after a column name to reverse the sort sequence.

PROC SQL ends with a QUIT statement.

PROC SQL;
SELECT col-name, col-name
         FROM input-table;
QUIT;

Subsetting data:

WHERE expression

Sorting data:

ORDER BY col-name <DESC>

Creating output data:

CREATE TABLE table-name AS

Deleting data:

DROP TABLE table-name;

Joining Tables Using SQL in SAS

An SQL inner join combines matching rows between two tables.

The two tables to be joined are listed in the FROM clause.

FROM from table1 INNER JOIN table2

ON table1.column = table2.column

Assign an alias (or nickname) to a table in the FROM clause by adding the keyword AS and the alias of your
choice. Then you can use the alias in place of the full table name to qualify columns in the other clauses of a
query. Although the AS keyword is not required, it can make the code easier to understand.

FROM table1 AS alias1, table2 AS alias2

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

You might also like