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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.