Looks like no one added any tags here yet for you.
Array
A collection of elements (normally SAS variables) that allow you to write SAS statements referencing this group of variables
Array statement
Used to create the array
Array names follow the same rules you use for SAS Variables. True or False?
True
Describe the syntax of an Array statement
Following the keyword ARRAY is the name you chose for your array. Array names follow the same rules you use for SAS variables. Following the array name, place the number of elements in brackets. Lastly, list the variables you want to include in the array. May use SAS shorthand for referring to a list of variables here, such as Var1-Varn
You may use ( ) or ( ) following the array name to specify the number of elements in the array
You may use square brackets [ ] or parentheses ( ) following the array name to specify the number of elements in the array
By placing the array in a DO Loop you can
process each variable in the array
Since we do not need or want the DO loop counter included in the SAS data set, we can use the
DROP statement
SAS arrays must contain all ( ) or all ( ) variables
numeric or character variables
If the variables you want to include in a character array are already defined as character then you can ( )
If the variables you want to include in a character array are already defined as character (for example, they are coming from a SET statement), you can write an ARRAY statement resembling the one in the previous section.
If you do not know the amount of variables in an array you can use an
asterisk
The keyword _CHARACTER_ is used as
the variable list
Because the _CHARACTER_ follows the SET statement, it includes all
the character variables in the Chars data set
Describe how to convert all character values to Propercase
May use the keyword _CHARACTER_ to reference all the character variables in the data set and then use a DO loop to convert all the values to Propercase
You can include variables in an ARRAY statement that does not exist in your SAS data set, True or False?
True
When creating a new variable- If no variables are listed and the number of elements is specified, SAS creates….
If no variables are listed and the number of elements is specified, SAS creates variable names automatically given by the name of the array followed by 1 to n such that n is the length of the array
By default, SAS numbers the elements of an array starting from…
1
Describe how to specify the beginning and ending values of the array elements…
You can use the lower and upper bounds in the brackets. following the array name and separate them with a colon
array Income {2010:2017} Income2010-Income2017;
array Income Taxes {2010:2017} Taxes2010-Taxes2017;
True or False? You can create an array that only has elements and no variables!
True
Elements of temporary arrays are great places to….
store values or perform table lookups
When can you assign the array elements initial values…
You can assign the array elements initial values when you create the temporary array or you can load values into the temporary array in the DATA step
Values in the temporary array are automatically retained; True or False
True, they are not set to missing values when the DATA step iterates.
What tells SAS that an array is temporary
_TEMPORARY_ tells SAS that this is a temporary array and the values in parentheses are the initial values for each of the elements of this array
Its important to remember that in making a temporary array, there are no…
corresponding variables
We can also load values for a temporary array from a file… True or False?
True
When loading values for a temporary array from a raw data file, we would use the value of _N_ when…
We use the value of N, when we want to read the first line of the data file, differently from the other lines. _N_ can be used to ensure that the answer key values are read only once.
The value of _N_ counts the
Iterations of the DATA step
SAS arrays may be multidimensional, true or false?
True
Describe a multidimensional array
Instead of having a single index to reference an element, we have multiple indices
When we have two dimensions, we can think of them as….
row and column indices
Describe how to define a multidimensional array
Specify the number of elements in each dimension in the brackets, following the array name, separated by commas
How would we define an array called MULTI with 3 elements on the first dimension and five elements on the second dimension
array Multi {3, 5} X1-X15;
To determine the number of elements in an multidimensional array…
you multiply the number of elements in each dimension