abhishekdagarit
9/27/2017 - 3:05 PM

SQL select statement

Basic SQL commands to be used in SAS as well as any other place.

SQL select statement

Select

Simplest Select satament

proc sql;
select * 
from sashelp.cars;
quit;

Where

proc sql;
select * 
from sashelp.cars
where make="Honda";
quit;

Group

proc sql;
select *
from sashelp.cars
where make="Honda" 
group by make;
quit;

As - renaming a variable as something else

proc sql;
select sum(price) as Total_Price
from sashelp.cars;
where make="Honda"
quit;

Having

Points to consider

  1. run; doesn't have any effect. You can use quit; instead.