SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Processing Variables with Arrays
Expanding Your Use of Arrays


Assigning Initial Values to Arrays

There are times when it is useful to assign initial values to elements of an array when you define the array.


     array goal{4} g1 g2 g3 g4 (initial values);

To assign initial values in an ARRAY statement,
  1. place the values after the array elements

     array goal{4} g1 g2 g3 g4 (9000 9300 9600 9900);

  1. specify one initial value for each corresponding array element

                   V  V  V  V
     array goal{4} g1 g2 g3 g4 (9000 9300 9600 9900);
                                ^    ^    ^    ^

  1. separate each value with a comma or blank

                                    V    V    V
     array goal{4} g1 g2 g3 g4 (9000 9300 9600 9900);

  1. enclose the initial values in parentheses

                               V                   V
     array goal{4} g1 g2 g3 g4 (9000 9300 9600 9900);

  1. enclose each character value in quotation marks.

                                    V   V V     V V    V
     array colors{3} color1-color3 ('red','white','blue');

  back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement