• No products in the cart.

What are the different arrays in SAS?

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.

21/02/2023
Template Design © Bodhan soft technologies PVT.LTD. All rights reserved. <meta name="facebook-domain-verification" content="cg6nsg7wc0h385jtk0v0gswpb924ti" />

Connect with :




Chat with Us
1
We are Online
Hello ,
How we can help you ?