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 [2-14]


Selecting Multiple Columns
SELECT *
FROM school;

We have learned how to select a single column from a SAS table.

Now, we will look at how to retrieve multiple columns using Proc SQL. 

[Reminder: if you haven't created the SCHOOL table, copy and run the code from the yellow box below in your SAS Studio.]​

Selecting multiple columns is fairly easy.

You simply list the columns in the SELECT clause separated by a comma.​

Example
Proc sql;
select Name, Age,
  Gender
from school;
quit;

In this example, student name, age and gender are listed in the SELECT clause.

​All three columns are retrieved and displayed in the output:​
Picture

​Note: each column is separated by a comma in the SELECT clause:
Picture


Selecting All Columns

You can also select all the columns by using the special character asterisk (*) in the SELECT clause.​

Example
Proc sql;
select *
from school;
quit;

​The asterisk (*) tells SAS to select all of the columns from the SAS table.

All five columns from the SCHOOL table are displayed:
Picture

Exercise

Locate the CARS table from the SASHelp library. 

Write a Proc SQL step to select the MAKE, MODEL and MSRP columns from the CARS table. 
Next

Need some help? 


HINT:
Simply list the three columns in the SELECT clause, separated by a comma.


SOLUTION:

Proc sql;
select make, model, msrp
from sashelp.cars;
quit;


Fill out my online form.
Already a member? Go to member's area.