In this ppt fundamentals codes of SAS SQL is given with the example and description. This will surely help you to build your notion on Data Analysis by using SAS SQL.
SAS SQL
Lesson 1.
SELECT statement
Lesson 2.
WHERE clause
Lesson 3.
GROUP BY clause
Lesson 4.
ORDER BY clause
Lesson 5.
JOIN clause
www.handsonsystem.com 2
SELECT statement:
proc sql;
select *
from mytable;
quit;
SAS SQL
The SELECT statement is used
to retrieve data from one or more
tables.
Example:
www.handsonsystem.com 3
WHERE clause
The WHERE clause is used
to filter rows based on a
condition.
proc sql;
select *
from mytable
where Sub = “Statistics” and
Score gt 70 ;
quit;
SAS SQL
www.handsonsystem.com 4
GROUP BY clause
The GROUP BY clause is used to group
rows based on one or more columns.
proc sql;
select dept, avg(salary)
from mytable
group by dept;
quit;
SAS SQL
www.handsonsystem.com 5
ORDER BY
clause
The ORDER BY clause is used to sort
the result set based on one or more
columns.
proc sql;
select *
from mytable
order by id;
quit;
SAS SQL
www.handsonsystem.com 6
JOIN clause
The JOIN clause is used to combine data
from two or more tables based on a common
column.
proc sql;
select *
from table1
inner join table2
on table1.id = table2.id;
quit;
SAS SQL
www.handsonsystem.com 7