In SAS, there are several types of arrays that can be used to store and manipulate data:
1. Numeric arrays: Numeric arrays are used to store numeric data in SAS. Each element of the array can hold a single numeric value.
array array_name[n] variable_1-variable_n;
array scores score1-score5;
do i = 1 to 5;
scores[i] = i*10;
2. Character arrays: Character arrays are used to store character data in SAS. Each element of the array can hold a single character value.
array array_name[n] $ variable_1-variable_n;
array names $ name1-name3;
names = ‘Alice’;
names = ‘Bob’;
names = ‘Charlie’;
3. Multidimensional arrays: Multidimensional arrays are used to store data in multiple dimensions, such as a matrix or a cube. Each element of the array is identified by a set of indices, one for each dimension.
array array_name[n, m, …] variable_1-variable_n, variable_1-variable_m, …;
array matrix[3, 3] score1-score9;
do i = 1 to 3;
do j = 1 to 3;
matrix[i,j] = i*j;
These are the main types of arrays in SAS, and they are similar to the arrays found in many other programming languages. The specific syntax and behavior of each array may vary depending on the SAS version being used.