Module 5: Combining SAS Data Sets Flashcards

1
Q

What are the two phases of data step processing?

A

1) Compilation phase
2) Execution phase

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

What happens during the compilaion phase?

A

1)Each statements within the data step are scanned for syntax errors
2)SAS identifies the type and length of each variable and creates a descriptor portion
3)Sets up Program Data Vector (PDV) with one row for 1 observation

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

What does the Program Data Vector (PDV) contain?

A
  • all variables in the source data
  • all variables created in the data step statements
  • automatic variables (helps count when sas moves on to next variable)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happends during the execution phase?

A

1) creates variables and sets all values to missing
2) Fills with source varaible from the 1st observation
3) Continues until all variables are filled
4) After its executed, moves on to the next observation

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

What happens when you stack two(+) data sets?

A

Stacks data on top of one another. For same variables, but different observations

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

Write the syntax to create permanent variables after merging or stacking data.

A

data name;
set data1 (in=a) data2 (in=b);
indataa = a;
indatab=b;
run;

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

T/F: An error message appears when trying to merge/stack variables with different lengths.

A

True: It warns you of possible truncation in the log

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

When merging or stacking variables, what properties of variables do you have to keep in mind?

A

1) length of variables
2) variable type

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

What step do you have to do before a merge?

A

Sort your data by a key (variable they both have in common)

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

T/F: Sort is automatically set to descending.

A

False: Set to ascending, need to specify descending for variables

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

What happens when you merge data sets that have more than one variables in common other than the BY variables?

A

SAS keeps the variable form the LAST input datafile

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

Given the following code, order which code gets executed first.

data check2;
set one;
keep x z;
rename x =firstname;
run;

A

1) runs keep statement first
2) renames x variable

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

T/F: The rename statement is always “executed” after the drop/keep statement.

A

True

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

T/F: Given the following code, x and y are outputs for three1 and…

data three1(keep=x y);
set one;
run;

no other variables are stored in the PDV memory

A

False: Other variables from data one are stored in PDV memory for this data step

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

T/F: Given the following code, the renamed variables are stored in…

data five3;
set two (rename=(a=group1 b=group2));
run;

the PDV.

A

True: It is renamed as it is read into the PDV.

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