| Working with Matrices |
You can create a vector by using the index operator (:). Three examples of statements involving index vectors follow:
> 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
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.