Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
Sentry Page Protection
Please Wait...
Proc SQL [1-15]


SELECT Statement
SELECT name
FROM school;
​
Proc SQL is often used to retrieve information from a SAS table.

Let's take a look at an example.

Copy and run the code from the yellow box below to get the SCHOOL table.

The SCHOOL table contains a list of students and their respective age, gender, school and height.
Picture

Now, we will retrieve just the students' name from the table using Proc SQL.
Picture

Example
Proc sql;
select name
from school;
quit;

The list of students are retrieved and displayed in the output:
Picture

(try it on your SAS Studio!)


​SELECT Statement
​
Let's go back to the code for a moment.

The Proc SQL step in our example contains a SELECT statement:
Picture
​
In this example, the SELECT statement has two clauses:
  • SELECT Clause and
  • FROM Clause
Picture

The SELECT clause selects the NAME column from the SAS table.

​The FROM clause specifies the SCHOOL table as the source of data.

Unlike data step, the SQL procedure ends with the QUIT statement as opposed to the RUN statement. ​​
Picture

Together with the SELECT clause and FROM clause, you can retrieve any columns from a SAS table.

Exercise

Locate the CARS table from the SASHelp library. 

Write a Proc SQL step to retrieve the list of car models from the CARS table.

​The car models are captured in the MODEL column.
Next

Need some help? 

Get Hint
Get Solution

Fill out my online form.

Home 
​1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Summary | Final Test | Coding Exercises
Already a member? Go to member's area.