Not applicable
Posts: 0

# Getting elements from a vector

I have a column of numbers
2
3
5
6
7
12
11
9
and I want to use them one by one in a do loop. How should I express the dimensions of that array to make the loop read the element of the first row, then the second row, etc...
Valued Guide
Posts: 653

## Re: Getting elements from a vector

We are almost certainly going to need more information before we can get you a fully satisfactory answer.

The DATA step has an implied loop that processes each row of a table one row at a time.
[pre]
data new;
set old;
......each value is processed one at a time ......
run;
[/pre]
Super Contributor
Posts: 3,176

## Re: Getting elements from a vector

Using a DATA step, you can load the input data and also use an ARRAY declaration to reference the variable list in a DO I=1 TO DIM(); END; code paragraph. The SAS support http://support.sas.com/ website had SAS-hosted DOC and supplemental technical and conference reference material on the topic.

Scott Barry
SBBWorks, Inc.

intro data step programming array site:sas.com
Not applicable
Posts: 0

## Re: Getting elements from a vector

This is what I'm trying to do...

data z.A9 z.B9;
/*This is the data set that contains the array "yr" which is a two dimensional array, rows(24) by columns(6)*/
array yr(6) yr1-yr6;
array f(6);
do n = 1 to 6;

f(n) = quantile('BINOM',yr(n),.5,10);

end;
/* Now in the following loop I want to use the numbers from the first column of the array f*/
/*I don't know how to express the dimensions of the array f in order to use the elements in each row of the array*/

do i=1 to 24;

x3=0;
do j=1 to f(1,i,1)???;
x2=7000+exp(5.12+0.92*rannor(123));
x3=x3+x2;

output z.A9;
** output to B only when J=f(1,i,1) in the inner loop;
if j=f(1,i,1) then x4=x4+x3;
if j=f(1,i,1) then output z.B9;
end;

output z.A9;

end;

run;
Super Contributor
Posts: 3,176

## Re: Getting elements from a vector

The SAS Support http://support.sas.com/ website has SAS-hosted DOC and supplemental technical / conference reference material on this topic/post. Here's one example using the site's SEARCH facility:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/e...

Scott Barry
SBBWorks, Inc.

dimensional array site:sas.com

introduction array site:sas.com

dim function site:sas.com
SAS Super FREQ
Posts: 9,365