Select the best answer
for each question. After completing the quiz, check your answers using
the answer key in the appendix.
-
According to the data
set descriptions below, which of the variables that are listed qualify
as BY variables for a DATA step match-merge?
-
-
-
-
There are no variables
that are common to both of these data sets.
-
Suppose you want to
merge Dataset1, Dataset2, and Dataset3. Also suppose that Dataset1
and Dataset2 have the common variable Startdate, that Dataset2 and
Dataset3 have the common variable Instructor, and that these data
sets have no other common variables. How can you use a DATA step to
merge these three data sets into one new data set?
-
You use a MERGE statement
in one DATA step to merge Dataset1, Dataset2, and Dataset3 by Startdate
and Instructor.
-
You sort Dataset1 and
Dataset2 by Startdate and merge them into a temporary data set in
a DATA step. Then you sort the temporary data set and Dataset3 by
Instructor and merge them into a new data set in a DATA step.
-
You can merge these
data sets only with a PROC SQL step.
-
You cannot merge these
three data sets at all because they do not have a common variable.
-
Which of the following
programs correctly creates a table with the results of a PROC SQL
inner join matched on the values of empcode?
-
proc sql;
select newsals.empcode allemps.lastname
newsals.salary contrib.amount
from sasuser.allemps, sasuser.contrib,
sasuser.newsals
where empcode=allemps.empid
and empcode=contrib.empid;
quit;
-
proc sql;
create table usesql as
select newsals.empcode allemps.lastname
newsals.salsry contrib.amount
from sasuser.allemps, sasuser.contrib,
sasuser.newsals
quit;
-
proc sql;
create table usesql as;
select newsals.empcode, allemps.lastname,
newsals.salary, contrib.amount;
from sasuser.allemps, sasuser.contrib,
sasuser.newsals;
where empcode=allemps.empid
and empcode=contrib.empid;
quit;
-
proc sql;
create table usesql as
select newsals.empcode, allemps.lastname,
newsals.salary, contrib.amount
from sasuser.allemps, sasuser.contrib,
sasuser.newsals
where empcode=allemps.empid
and empcode=contrib.empid;
quit;
-
To process a default
DATA step match-merge, SAS first reads the descriptor portion of each
input data set to create the PDV and the descriptor portion of the
new data set. Which of the following accurately describes the rest
of this process?
-
Next, SAS sequentially
match-merges observations reading them into the PDV, and then writes
them to the new data set. When the BY value changes in all the input
data sets, the PDV is initialized to missing. Missing values for variables,
as well as missing values that result from unmatched observations,
are written to the new data set.
-
Next, SAS sequentially
match-merges observations reading them into the PDV, and then writes
them to the new data set. After each DATA step iteration, the PDV
is initialized to missing. Missing values for variables, as well as
missing values that result from unmatched observations, are omitted
from the new data set.
-
Next, SAS creates a
Cartesian product of all possible combinations of observations, writes
them to the PDV, and then to the new data set. Then SAS goes through
the new data set and eliminates all observations that do not have
matching values of the BY variable.
-
Next, SAS creates a
Cartesian product of all possible combinations of observations, writes
them to the PDV, and then to the new data set. The new data set is
then ordered by values of the BY variable.
-
Which of the following
statements is false about using multiple SET statements in one DATA
step?
-
You can use multiple
SET statements to combine observations from several SAS data sets.
-
Processing stops when
SAS encounters the end-of-file (EOF) marker on either data set (even
if there is more data in the other data set).
-
You can use multiple
SET statements in one DATA step only if the data sets in each SET
statement have a common variable.
-
The variables in the
PDV are not reinitialized when a second SET statement is executed.
-
Select the program that
correctly creates a new data set named Sasuser.Summary that contains
one observation with summary data that was created from the Salary
variable of the Sasuser.Empdata data set.
-
proc sum data=sasuser.emdata noprint;
output out=sasuser.summary sum=Salarysum;
run;
-
proc means data=sasuser.empdata noprint;
var salary;
output out=sasuser.summary sum=Salarysum;
run;
-
proc sum data=sasuser.empdata noprint;
var salary;
output out=sasuser.summary sum=Salarysum;
run;
-
proc means data=sasuser.empdata noprint;
output=sasuser.summary sum=Salarysum;
run;
-
If the value of Cargosum
is $1000 at the end of the first iteration of the DATA step shown
below, what is the value of Cargosum in the PDV when the DATA step
is in its third iteration?
data sasuser.percent1;
if _n_=1 then set sasuser.summary (keep=cargosum);
set sasuser.monthsum (keep=salemon revcargo);
PctRev=revcargo/cargosum;
run;
-
-
-
-
The value cannot be
determined without seeing the data that is in Sasuser.Summary.
-
According to the data
set shown, what is the value of Totalrev in the PDV at the end of
the fourth iteration of the DATA step?
data sasuser.percent2(drop=totalrev);
if _n_=1 then do until(lastobs);
set sasuser.monthsum2(keep=revcargo)
end=lastobs;
totalrev+revcargo;
end;
set sasuser.monthsum2
(keep=salemon revcargo);
PctRev=revcargo/totalrev;
run;
|
|
-
Which of the following
programs correctly uses an index to combine data from two input data
sets?
-
data work.profit;
set sasuser.sale2000(keep=routeid flightid date
rev1st revbusiness revecon revcargo)
key=flightdate;
set sasuser.dnunder;
Profit=sum(rev1st, revbusiness, revecon, revcargo,
-expenses);
run;
-
data work.profit;
set sasuser.dnunder;
set sasuser.sale2000(keep=routeid flightid date
rev1st revbusiness revecon revcargo)
key=flightdate;
where routeid='0000103';
Profit=sum(rev1st, revbusiness, revecon, revcargo,
-expenses);
run;
-
data work.profit;
set sasuser.dnunder;
set sasuser.sale2000(keep=routeid flightid date
rev1st revbusiness revecon revcargo);
key=flightdate;
Profit=sum(rev1st, revbusiness, revecon, revcargo,
-expenses);
run;
-
data work.profit;
set sasuser.dnunder;
set sasuser.sale2000(keep=routeid flightid date
rev1st revbusiness revecon revcargo)
key=flightdate;
Profit=sum(rev1st, revbusiness, revecon, revcargo,
-expenses);
run;
-
Which of the following
statements about the _IORC_ variable is false?
-
It is automatically
created when you use either a SET statement with the KEY= option or
the MODIFY statement with the KEY= option in a DATA step.
-
A value of zero for
_IORC_ means that the most recent SET statement with the KEY= option
(or MODIFY statement with the KEY= option) did not execute successfully.
-
A value of zero for _IORC_ means that
the most recent SET statement with the KEY= option (or MODIFY statement
with the KEY= option) executed successfully.
-
You can use the _IORC_
variable to prevent nonmatching data from being included when you
use an index to combine data from multiple data sets.