1.4 Flashcards

1
Q

Which of the following is true regarding the DATA step?

a) The DATA statement reads the input table, or existing table that you are reading.
b) The SET statement names the output table, or the table you want to create.
c) If the output table you list in the DATA statement exists and you have write access to it, the DATA step overwrites that table.
d) The output table is always temporary. You need to use a PROC statement to permanently assign it to a library.

A

c) If the output table you list in the DATA statement exists and you have write access to it, the DATA step overwrites that table.

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

Which of the following is NOT a phase of the DATA step?

a) Compilation
b) Execution
c) Log Generation
d) Debugging
e) c & d

A

e) c & d

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

Which of the following is done during the execution phase of the DATA step?

a) SAS checks for syntax errors in the program
b) SAS established the table metadata
c) Default labels are established for all columns
d) SAS reads the data, processes it, and writes it to the output table one row at a time.

A

d) SAS reads the data, processes it, and writes it to the output table one row at a time.

a and b are done during compilation phase

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

True/False - The DATA step includes an implied OUTPUT action where a new row is written to the output table.

A

True - This occurs at the end of the DATA step.

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

True/False - The DATA step compilation phase acts like an automatic loop.

A

False - The DATA step execution phase is like an automatic loop. The first time through the DATA step, the SET statement reads row number one from the input table and then processes any other statements in the sequence, manipulating the values within that row. When SAS reaches the end of the DATA step, there is an implied OUTPUT action, and the new row is written to the output table. The DATA step then automatically loops back to the top and executes the statements in order again, this time reading, manipulating, and outputting the second row. That implicit loop continues until all of the rows are read from the input table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Which of the following DATA steps 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)
data out.storm_new;
set pg1.storm_summary;
run;

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

Which data sources can be used in the SET statement (list 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
8
Q

Given the table below, which DATA step would result in 2 columns in the output table?

ID Month Year
1 Jan 2020

a) data mydata;
   keep=ID Month;
        set pg1.mydata;    
  run;
b) data mydata;   
        set pg1.mydata keep=ID Month;;    
  run;
c) data mydata;   
        set pg1.mydata;    
   keep ID Month;
   run;
d) data mydata;   
        set pg1.mydata;    
    drop Year;
   run;
e) c & d
A

e) c & d

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

Which of the following is needed to create a new column derived from an existing column in SAS?

a) a conditional expression
b) a global statement
c) an assignment statement
d) a retain statement

A

c) an assignment statement

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

What are the new columns generated from the following DATA step?

data cars_new;
   set sashelp.cars;
   where Origin ne "USA";
   Profit = MSRP-Invoice;
   Source = "Non-US Cars";
   format Profit dollar10.;
   keep Make Model MSRP Invoice Profit Source;
run;

a) Origin, Make
b) Make, Model, MSRP, Invoice, Profit, Source
c) no new columns are created
d) Profit and Source

A

d) Profit and Source
New columns are assigned in a DATA step by typing the name of the new column, an equal sign, and then the expression that creates the new data value.

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

Which of the following is NOT true regarding SAS functions?

a) A function is a defined routine that returns a value
b) The syntax for a function is the function name, followed by the arguments enclosed in parentheses.
c) All arguments must be enclosed with quotes.
d) All arguments must be separated with commas.

A

c) All arguments must be enclosed with quotes.

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

True/False - Functions cannot be used as part of assignment statements in a SAS DATA step?

A

False - Functions can be used in assignment statements to generate a value for the column

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

Which of the following is NOT a commonly used summary function that calculates summary statistics?

a) SUM(num1, num2,…)
b) MEAN(num1, num2,…)
c) NMISS(num1, num2,…)
d) MISS(num1, num2,…)

A

d) MISS(num1, num2,…) is not a function

MISSING(numeric-expression | character-expression) is a SAS function.

NMISS(num1, num2,…) is a summary function

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

Which of the following is true regarding SAS summary functions?

a) Functions can have up to 10 arguments
b) Summary functions ignore missing values
c) Functions can contain numeric or character arguments
d) All of the above are true

A

b) Summary functions ignore missing values

a - Summary functions can have unlimited arguments
b - Functions must include numeric constant or numeric columns as arguments.

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