4: Preparing Data Flashcards

1
Q

Which DATA step creates a permanent output data set?

 a.  data storm_new;
   set pg1.storm_summary;   run;

 b.  data out.storm_new;
   set pg1.storm_summary;   run;

 c.  data work.storm_new;
   set pg1.storm_summary;   run;
A

B

This DATA step creates the storm_new table in the OUT library.

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

Which data sources can be used in the SET statement? Select all that apply.

 a. SAS tables
 b. Excel spreadsheets
 c. DBMS tables
 d. comma-delimited files
A

A,B,C

Any data source that can be read via a library can be used as the input table in the SET statement.

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

In which phase does the DATA step check for syntax errors?

 a. compilation
 b. execution
A

A

Checking for syntax errors is the first step in the compilation phase.

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

Which statement is used to read a SAS data set in a DATA step?

 a. DATA statement
 b. WHERE statement
 c. SET statement
 d. assignment statement
A

C
The SET statement indicates the table that will be read. The DATA statement indicates the table that will be created or updated.

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

To process an Excel file with the DATA step, you must first create a copy of the data as a SAS table.

 a. True
 b. False
A

B

You can use the XLSX LIBNAME engine to read an Excel worksheet directly and process the data with the DATA step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
What is the name of the ouput data set in the program below?
data work.us;
    set orion.sales;
    where Country='US';
run;
 a. work.us
 b. orion.sales
 c. Country
 d. sales
A

A

The output table is listed in the DATA statement.

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

The data set orion.sales contains nine columns. Given this DATA step, how many columns does work.comp have?
data work.comp;
set orion.sales;
keep employee_id status job_title salary;
run;

 a. four
 b. nine
 c. five
A

A

Only the four columns listed in the KEEP statement are written to the work.comp table.

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

Given the assignment statement below, what is the value of AvgExp for the observation that is shown?
AvgExp=mean(Exp1, Exp2, Exp3, Exp4);

Exp1 Exp2 Exp3 Exp4
10 . 5 9

 a. 6
 b. 8
 c. . (missing value)
 d. The statement generates a syntax error.
A

B

The MEAN function ignores missing values, so the calculation is (10+5+9)/3=8.

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

Which of the following SAS functions returns a number from 1 to 12?

 a. YEAR(SAS-date-value)
 b. MONTH(SAS-date-value)
 c. WEEKDAY(SAS-date-value)
 d. none of the abov
A

B

The MONTH function returns the month number (1-12) extracted from a SAS date value.

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

in the program below, what is the value of Credit if Country is ‘au’?
data work.bonus;
set orion.sales;
if Country=’US’ then Credit=300;
else if Country=’AU’ then Credit=500;
else Credit=0;
run;

 a. 300
 b. 500
 c. 0
 d. missing
A

C
The character conditions are case sensitive. The first two IF conditions are false. Therefore, the final ELSE statement assigns Credit a value of zero.

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

What is the length of the Car_Type column created in this program?
data car_type;
set sashelp.cars;
if msrp>80000 then car_type=”luxury”;
else car_type=”regular”;
length car_type $ 8;
run;

 a. 6
 b. 7
 c. 8
A

A
When the DATA step is compiled, the first mention of Car_Type determines the column name, type, and length. The length is determined by the value in the assignment statement. The value luxury has six characters, so the length is 6.

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

Use a DO group in a DATA step when you want to execute multiple statements for a true IF-THEN expression.

 a. True
 b. False
A

A

To execute more that one statement if a condition is true, you must use IF-THEN/DO groups.

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