1.7 Flashcards

1
Q

True/False - At a minimum, an SQL query must specify a list of column names to retrieve in the SELECT clause and the name of the table that contains the columns in the FROM clause.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is false regarding the SQL statement below?

proc sql;
select Name, Age, Height, Birthdate format=date9.
from pg1.class_birthdate;
quit;

a) This query selects columns from the pg1.class_birthdate table and generates a report.
b) The SELECT clause specifies the columns that you want to appear in the result.
c) Column names are always separated with commas.
d) The format applied to Birthdate is part of standard SQL syntax.

A

d) The format applied to Birthdate is not standard SQL syntax, this SAS extension to the SQL language makes it easier to create more useful and polished reports.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In PROC SQL, which clause do you use to sort the report that is produced?

a) WHERE
b) BY
c) SORT
d) ORDER BY

A

d) ORDER BY

If you want to order the rows in descending order, you would add the DESC keyword after the column name in the ORDER BY clause.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following SQL procedures will generate a table instead of a report?

a) proc sql;
    create table myclass as
         select Name, Age, Height
         from pg1.class_birthdate
         where age > 14
         order by Height desc;
   quit;
b)  proc sql;
    create table myclass as;
         select Name, Age, Height
         from pg1.class_birthdate
         where age > 14
         order by Height desc;
   quit;
c)  proc sql;
         select Name, Age, Height
         from pg1.class_birthdate
         where age > 14
         order by Height desc;
   quit;
A
a) proc sql;
    create table myclass as
         select Name, Age, Height
         from pg1.class_birthdate
         where age > 14
         order by Height desc;
   quit;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which of the following will drop a table?

a) ODS drop table work.myclass;
b) options drop table work.myclass;
c) proc sql;
drop table work.myclass;
quit;
d) proc sql;
delete table work.myclass;
quit;

A

c) proc sql;
drop table work.myclass;
quit;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True/False - An inner join creates a new report or table that includes only the records found in both tables.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following is correct syntax for an inner join?
a) FROM table1 INNER JOIN table2
ON table1.column=table2.column
b) FROM table1 INNER JOIN table2
ON column1=column2
c) FROM table1
INNER JOIN table2 table1.column=table2.column

A

a) FROM table1 INNER JOIN table2

ON table1.column=table2.column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What keyword is needed when assigning an alias to a table?

a) ALIAS
b) AS
c) IS
d) No keyword is necessary

A

b) AS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When comparing SQL to the SAS DATA step, which of the following is NOT true?

a) SQL is an ANSI-standard language used by most databases
b) code can be more streamlined
c) can manipulate, summarize, and sort data in one step
d) SQL provides more control of reading, writing, and manipulating data

A

d) The DATA step provides more control of reading, writing, and manipulating data than SQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

True/False - You can use SQL for looping and array processing.

A

False - This is possible with the SAS DATA step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

True/False - You cannot produce multiple output tables in one SQL query.

A

True - This is possible with the SAS DATA step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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…

A

d) select…from…where…order by…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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.

A

c) Formats can be specified in the FROM clause.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

d) Height/Weight as Ratio

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

c) create table work.new as

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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;
A
b) select Name, Height
        from sashelp.class
        where age=12
        order by Height desc;
17
Q

Which SQL statement can delete tables?

a) DROP
b) VOID
c) DELETE
d) SELECT

A

a) DROP

18
Q
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;
A

c) select ID, Name, Salary
from one inner join two
on ID=IDNO;

19
Q
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;
A

d) from empsau inner join phonec

on empsau.empid=phonec.empid;

20
Q

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

A

c) from empsau as e inner join phonec as p