BookmarkSubscribeRSS Feed
azt5173
Obsidian | Level 7

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. 

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

And you want to use an array doing this or?

azt5173
Obsidian | Level 7

Array or anything useful that will help me do this. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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