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.
Syntax:
Â
array array_name[n] variable_1-variable_n;
Example
data test;
 array scores[5] score1-score5;
 do i = 1 to 5;
   scores[i] = i*10;
 end;
run;
2. Character arrays: Character arrays are used to store character data in SAS. Each element of the array can hold a single character value.
Syntax:
array array_name[n] $ variable_1-variable_n;
Â
Â
data test;
 array names[3] $ name1-name3;
 names[1] = ‘Alice’;
 names[2] = ‘Bob’;
 names[3] = ‘Charlie’;
run;
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.
Syntax:
array array_name[n, m, …] variable_1-variable_n, variable_1-variable_m, …;
Example:
data test;
 array matrix[3, 3] score1-score9;
 do i = 1 to 3;
   do j = 1 to 3;
     matrix[i,j] = i*j;
   end;
 end;
run;
Â
Â
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.
Enroll for instructor led training free demo
Course Categories
SAS Tutorial For Beginners
- adtest
- test
- SAS Programming Global Options
- SAS Programming Fundamentals
- SAS Numeric Formats
- SAS Date Formats
- SAS Programming Macros
- SAS Programming SQL
- What are the different options in transpose?
- SAS Programming Graphs
- What are the different options in proc tabulet?
- What are the different options in proc report?
- What are the different options in proc freq?
- What are the different options in proc means?
- What are the different arrays in SAS?
- What are the different loops in SAS?
- What are the different options in conditional statements?
- What are the different options in merge?
- SAS Programming proc print & proc sort options?
- SAS Programming Functions
- SAS Programming proc import & Proc Export options?
- SAS Programming Data Set Options in SAS?
- SAS Programming proc format?
- SAS Programming Infile options
- SAS Programming input methods
- What are the Proc Contents in SAS?
- How to create SAS Libiray?
- How to create simple Program in SAS?
- SAS Software windows
- SAS Introduction