Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Working with Matrices

Index Vectors

You can create a vector by using the index operator (:). Several examples of statements involving index vectors are shown in the following code:

   >  r=1:5;

                R             1 row       5 cols    (numeric)
                        1         2         3         4         5

   >  s=10:6;

                S             1 row       5 cols    (numeric)
                       10         9         8         7         6

   >  t='abc1':'abc5';

                T             1 row       5 cols    (character, size 4)
                               abc1 abc2 abc3 abc4 abc5
If you want an increment other than 1, use the DO function. For example, if you want a vector ranging from -1 to 1 by 0.5, use the following statement:
   >  r=do(-1,1,.5);

                R             1 row       5 cols    (numeric)
                       -1      -0.5         0       0.5         1

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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