Ch 6: Creating Reports Flashcards

1
Q

Which PROC PRINT step below creates the sample output with the labels and variables being displayed? Hint: PROC CONTENTS output is shown first to assist you.

a.
proc print data=cert.laguardia noobs;
var on changed flight;
where on>=160;
run;
b.
proc print data=cert.laguardia;
var date on changed flight;
where changed>3;
run;
c.
proc print data=cert.laguardia label;
id date;
var boarded transferred flight;
label boarded=’On’ transferred=’Changed’;
where flight=’219’;
run;
d.
proc print cert.laguardia noobs;
id date;
var date on changed flight;
where flight=’219’;
run;

A

Correct answer: c The DATA= option specifies the data set that you are listing, and the ID statement replaces the Obs column with the specified variable. The VAR statement specifies variables and controls the order in which they appear, and the WHERE statement selects rows based on a condition. The LABEL option in the PROC PRINT statement causes the labels that are specified in the LABEL statement to be displayed.

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

Which of the following PROC PRINT steps is correct if labels are not stored with the data set?
a.
proc print data=cert.totals label;
label region8=’Region 8 Yearly Totals’;

run;
b.
proc print data=cert.totals;
label region8=’Region 8 Yearly Totals’;
run;
c.
proc print data cert.totals label noobs;
run;
d.
proc print cert.totals label;
run;

A

Correct answer: a
You use the DATA= option to specify the data set to be printed. The LABEL option specifies that variable labels appear in output instead of in variable names.

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

Which of the following statements selects from a data set only those observations for which the value of the variable Style is RANCH, SPLIT, or TWOSTORY?
a.
where style=’RANCH’ or ‘SPLIT’ or ‘TWOSTORY’;
b.
where style in ‘RANCH’ or ‘SPLIT’ or ‘TWOSTORY’;
c.
where style in (RANCH, SPLIT, TWOSTORY);
d.
where style in (‘RANCH’,’SPLIT’,’TWOSTORY’);

A

Correct answer: d

In the WHERE statement, the IN operator enables you to select observations based on several values. You specify values in parentheses and separated by spaces or commas. Character values must be enclosed in quotation marks and must be in the same case as in the data set.

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

If you want to sort your data and create a temporary data set named Calc to store the sorted data, which of the following steps should you submit?
a.
proc sort data=work.calc out=finance.dividend;
run;
b.
proc sort dividend out=calc;
by account;
run;
c.
proc sort data=finance.dividend out=work.calc;
by account;
run;
d.
proc sort from finance.dividend to calc;
by account;
run;

A

Correct answer: c
In a PROC SORT step, you specify the DATA= option to specify the data set to sort. The OUT= option specifies an output data set. The required BY statement specifies the variable or variables to use in sorting the data.

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

Which of the following statements can you use in a PROC PRINT step to create this output?
a.
var month instructors;
sum instructors aerclass walkjogrun swim;
b.
var month;
sum instructors aerclass walkjogrun swim;
c.
var month instructors aerclass;
sum instructors aerclass walkjogrun swim;
d.
all of the above

A

Correct answer: d
You do not need to name the variables in a VAR statement if you specify them in the SUM statement, but you can. If you choose not to name the variables in the VAR statement as well, then the SUM statement determines their order in the output.

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

What happens if you submit the following program?
proc sort data=cert.diabetes;
run;
proc print data=cert.diabetes;
var age height weight pulse;
where sex=’F’;
run;
a.
The PROC PRINT step runs successfully, printing observations in their sorted order.
b.
The PROC SORT step permanently sorts the input data set.
c.
The PROC SORT step generates errors and stops processing, but the PROC PRINT step runs successfully, printing observations in their original (unsorted) order.
d.
The PROC SORT step runs successfully, but the PROC PRINT step generates errors and stops processing.

A

Correct answer: c
The BY statement is required in PROC SORT. Without it, the PROC SORT step fails. However, the PROC PRINT step prints the original data set as requested.

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

If you submit the following program, which output does it create?
proc sort data=cert.loans out=work.loans;
by months amount;
run;

proc print data=work.loans noobs;
var months amount payment;
sum amount payment;
where months<360;
run;

A

Correct answer: a
Column totals appear at the end of the report in the same format as the values of the variables, so b is incorrect. Work.Loans is sorted by Month and Amount, so c is incorrect. The program sums both Amount and Payment, so d is incorrect.

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

Which statement below selects rows that satisfy both these conditions?

The amount is less than or equal to $5000.

The account is 101-1092 or the rate equals 0.095.
a.
where amount <= 5000 and

account=’101-1092’ or rate = 0.095;
b.
where (amount le 5000 and account=’101-1092’)
or rate = 0.095;
c.
where amount <= 5000 and
(account=’101-1092’ or rate eq 0.095);
d.
where amount <= 5000 or account=’101-1092’
and rate = 0.095;

A

Correct answer: c
To ensure that the compound expression is evaluated correctly, you can use parentheses to group the observations:
account=’101-1092’ or rate eq 0.095

For example, from the data set above, a and b select observations 2 and 8 (those that have a rate of 0.095); c selects no observations; and d selects observations 4 and 7 (those that have an amount less than or equal to 5000).

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

What does PROC PRINT display by default?
a.
PROC PRINT does not create a default report; you must specify the rows and columns to be displayed.
b.
PROC PRINT displays all observations and variables in the data set. If you want an additional column for observation numbers, you can request it.
c.
PROC PRINT displays columns in the following order: a column for observation numbers, all character variables, and all numeric variables.
d.
PROC PRINT displays all observations and variables in the data set, a column for observation numbers on the far left, and variables in the order in which they occur in the data set.

A

Correct answer: d
By default, PROC PRINT prints all observations and variables. An Obs column is generated to identify the observation number, and variables and observations appear in the order in which they occur in the data set.

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