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

Summary of Lesson 7 - Using SQL in SAS

Uploaded by

Anubhav Bigamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Summary of Lesson 7 - Using SQL in SAS

Uploaded by

Anubhav Bigamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

7/18/2021 Summary of Lesson 7: Using SQL in SAS

Print     

Summary of Lesson 7: 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
https://vle.sas.com/pluginfile.php/800800/mod_scorm/content/274/07/summary07.htm 1/2
7/18/2021 Summary of Lesson 7: Using SQL in SAS

in the other clauses of a query.

FROM table1 AS alias1, table2 AS alias2

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

https://vle.sas.com/pluginfile.php/800800/mod_scorm/content/274/07/summary07.htm 2/2

You might also like