7: Using SQL in SAS Flashcards
What is the correct order of the following four clauses? a. from ... select ... where ... order by ...
b. order by ... from ... select ... where ... c. select ... where ... order by ... from ... d. select ... from ... where ... order by ...
D
First is SELECT, second is FROM, third is WHERE, and fourth is ORDER BY.
Which of the following is false regarding the SQL procedure?
a. Column names are separated with commas. b. The procedure ends with a QUIT statement. c. Formats can be specified in the FROM clause. d. The SELECT and FROM clauses are required in the SELECT statement.
C
Formats are specified in the SELECT clause after the column name.
Which syntax is valid for creating a computed column in the SELECT clause?
a. Ratio = Height/Weight b. Ratio as Height/Weight c. Height/Weight = Ratio d. Height/Weight as Ratio
D
Computed columns are created by specifying the expression, the keyword AS, and the column name, in that order.
The SELECT statement creates a report. Which clause can be added before the SELECT clause to create a table?
a. create work.new = b. create work.new table c. create table work.new as d. create table=work.new as
C
To create a table, add the CREATE TABLE NEW-TABLE-NAME AS clause before the SELECT clause.
Which SELECT statement produces the given output? Name Height Thomas 57.5 Joyce 51.3 a. select Name Height from sashelp.class where age=12 order by Height;
b. select Name, Height from sashelp.class where age=12 order by Height desc;
c. select Name Height from sashelp.class where age=12 order by desc Height;
d. select Name, Height from sashelp.class where age=12 order by desc Height;
B
In the SELECT clause, column names are separated with commas. In the ORDER BY clause, DESC goes after the column name. ASC is the default sort order.
Which SQL statement can delete tables?
a. DROP b. VOID c. DELETE d. SELECT
A
The DROP TABLE statement deletes tables.
f an inner join is performed on the following tables based on the ID and IDNO columns, how many rows will be in the PROC SQL report? Name ID Jack 111 Mary 333 Jane 555 IDNO Salary 111 75000 222 83000 333 82000
a. one b. two c. three d. four
B
An inner join gives matches only. Jack (111) and Mary (222) are the matches in this example.
Which statement has the correct syntax for performing an inner join?
a. select ID, Name, Salary
from one join two
on ID=IDNO;
b. select ID, Name, Salary from one join two where ID=IDNO; c. select ID, Name, Salary from one inner join two on ID=IDNO; d. select ID, Name, Salary from one inner join two where ID=IDNO;
C
To perform an inner join, specify INNER JOIN between two table names and specify the matching condition in an ON clause (not a WHERE clause).
Which ON clause has valid qualifying syntax?
a. from empsau inner join phonec
on e.empid=p.empid;
b. from empsau inner join phonec on left.empid=right.empid; c. from empsau inner join phonec on first.empid=second.empid; d. from empsau inner join phonec on empsau.empid=phonec.empid;
D
To qualify a column, put the table name and a period before the column name. Qualifying is needed when a column is in multiple tables. The name empsau.empid refers to the empid column in the empsau table.
Which FROM clause properly creates aliases?
a. from empsau=e inner join phonec=p b. from empsau(e) inner join phonec(p) c. from empsau as e inner join phonec as p d. from empsau of e inner join phonec of p
C
To create an alias in the FROM clause, put the word AS and the alias after the table name. The word AS is optional. The alias can be used when qualifying a column.