Select the best answer
for each question. After completing the quiz, check your answers using
the answer key in the appendix.
-
A Cartesian product
is returned when
-
join conditions are
not specified in a PROC SQL join.
-
join conditions are
not specified in a PROC SQL set operation.
-
more than two tables
are specified in a PROC SQL join.
-
the keyword ALL is used
with the OUTER UNION operator.
-
Given the PROC SQL query
and tables shown below, which output is generated?
proc sql;
select *
from store1,
store2
where store1.wk=
store2.wk;
|
|
-
Given the PROC SQL query
and tables shown below, which output is generated?
proc sql;
select s.*, bonus
from bonus as b
right join
salary as s
on b.id=
s.id;
|
|
-
Which PROC SQL query
produces the same output as the query shown here?
proc sql;
select a.*,
duration
from groupa as a,
groupb as b
where a.obs=b.obs;
Note: Assume that the table Groupa
contains the columns Obs and Med. Groupb contains the columns Obs
and Duration.
-
proc sql;
select a.obs label='Obs',
med
b.obs label='Obs',
duration
from groupa as a, groupb as b
where a.obs=b.obs;
-
proc sql;
select coalesce(a.obs, b.obs)
label='Obs', med, duration
from groupa as a
full join
groupb as b
on a.obs=b.obs;
-
proc sql;
select a.*, duration
from groupa as a
left join
groupb as b
where a.obs=b.obs;
-
proc sql;
select a.*, duration
from groupa as a
inner join
groupb as b
on a.obs=b.obs;
-
Which output is generated
by the following PROC SQL query?
proc sql;
select *
from table1
left join
table2
on table1.g3=
table2.g3;
|
|
-
In order for PROC SQL
to perform an inner join,
-
the tables being joined
must contain the same number of columns.
-
the tables must be sorted
before they are joined.
-
the columns that are
specified in a join condition in the WHERE clause must have the same
data type.
-
the columns that are
specified in a join condition in the WHERE clause must have the same
name.
-
Which statement about
in-line views is false?
-
Once defined, an in-line
view can be referenced in any PROC SQL query in the current SAS session.
-
An in-line view can
be assigned a table alias but not a permanent name.
-
In-line views can be
combined with tables in PROC SQL joins.
-
This PROC SQL query
contains an in-line view that uses valid syntax:
proc sql;
select name, numvisits
from (select name, sum(checkin)
as numvisits
from facility as f, members as m
where area='POOL' and
f.id=m.id
group by name)
where numvisits<=10
order by 1;
-
Which PROC SQL query
generates the same output as the DATA step match-merge and PRINT step
shown below?
data merged;
merge table1 table2;
by g3;
run;
proc print data=merged
noobs;
title 'Merged';
run;
|
|
-
proc sql;
title 'Merged';
select a.g3, z, r
from table1 as a
full join
table2 as b
on a.g3 = b.g3
order by 1;
-
proc sql;
title 'Merged';
select a.g3, z, r
from table1 as a
table2 as b
on a.g3 = b.g3
order by 1;
-
proc sql;
title 'Merged';
select coalesce(a.g3, b.g3)
label='G3', z, r
from table1 as a
full join
table2 as b
on a.g3 = b.g3
order by 1;
-
proc sql;
title 'Merged';
select g3, z, r
from table1 as a
full join
table2 as b
on a.g3 = b.g3
order by 1;
-
A PROC SQL inner join
can combine
-
a maximum of 2 tables
or in-line views, but multiple joins can be chained together.
-
a maximum of 256 tables
or 2 in-line views.
-
a maximum of 256 tables,
which includes any tables referenced by an in-line view.
-
a maximum of 2 tables
and 32 columns.
-
Which statement about
the use of table aliases is false?
-
Table aliases must be
used when referencing identical table names from different libraries.
-
Table aliases can be
referenced by using the keyword AS.
-
Table aliases (or full
table names) must be used when referencing a column name that is the
same in two or more tables.
-
Table aliases must be
used when using summary functions.