## Using an array to count allocations in clinical trial

Occasional Contributor
Posts: 15

# Using an array to count allocations in clinical trial

I am working on a clinical trial where I have to count the updated allocation of each treatments. There are 3 treatments(T)(1,2,3) and 3 age factors(J)(1,2,3). The current data set looks like this:

Subject   T     J

1             3    1

2             2     2

3             1     3

4              5    1

5              2     3

........................

2310        1      3

If J=1 and T=1 are equal to each other then Z11(variable for allocation) increases by 1

If J=1 and T=2  then Z12 count remains the same.

if J=1 and T=3  then Z13 count remains the same.

The above condition repeats for when J=2 and when J=3. And iterates each time a subject is added into the trial.

So basically Zjt=count+1 if T=J and Zjt=count if T is not equal to Z.

The dataset Z should look something like this

Z11 Z12 Z13 Z21 Z22 Z23 Z31 Z32 Z33

6     1     4      7     5      9    10    15   12

I wrote the code below but it does not give me the result I want

data z;
set data;
array a z11-z13;
do i=1 to dim(a);
if t=1 and fac1=1 then z11=count+1;
else if t=2 and fac1=1 then z12=count;
else if t=3 and fac1=1 then z13=count;
end;
run;

Thank you for any help at all.

PROC Star
Posts: 1,283

## Re: Using an array to count allocations in clinical trial

And you want to use an array doing this or?

Occasional Contributor
Posts: 15

## Re: Using an array to count allocations in clinical trial

Array or anything useful that will help me do this.

Discussion stats
• 2 replies
• 54 views
• 0 likes
• 2 in conversation