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.
And you want to use an array doing this or?
Array or anything useful that will help me do this.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.