Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- creating a loop for clinical trials

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-19-2018 03:19 PM

I am working on a clinical trial with 2310 subjects where I have to randomize treatments. The randomization consists of one factor(fac) "Age" where the categories are "1" if >18 and" 2" if 6 to <18 and "3" if <6. The treatments are A, B,C. The initial enrollment for each subject is defined as Xjk where K is the treatment(A, B, C) and j is the age factor(1,2,3). So you would have XjA, XjB and Xjc possibilities for each subject. The initial data looks like this:

Subject Fac X Treatment

1 2 XjA A

2 1 XjB B

3 2 XjC C

4 3 XjA A

........

2310 1 XjC A

I need to design a variable(Mjk) that's going to count the updated allocation if a new subject with a different j value is going to come in, for example M11 would be where age factor=1(j) and treatment=1(k) for the particular subject, M12 would be age factor=1 and treatment=2 for that subject, so I need to check within each subject and I am not sure how to do that. I am very new to SAS so I don't know how to design this in loops, I initially did an if/else statement but this was not accounting for each new subject. The initial code is shown below:

data m12;

set data;

if fac1="1" then do;

if X="XjB" and t="2" then M="M12";

data m13;

set data;

if fac1="1" then do;

if X="Xjc" and t="3" then m="m13";

end;

run;

Any help at all would be greatly appreciated! Thank you.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to azt5173

06-19-2018 07:29 PM

Sorry your question is unclear.

What's the output you expect for the example you provided?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ChrisNZ

06-19-2018 09:26 PM

Hi, I am sorry here is an updated question:

The variable Mjk is going to look at the X variable and the fac variable for each subject and update the allocation based on each subject.

So the data set should look like this:

Subject Fac X Treatment M

1 2 XjA A M2A

2 1 XjB B M1B

3 2 XjC C M2C

4 3 XjA A M3A

........

2310 1 XjC A M1A

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to azt5173

06-19-2018 09:42 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ChrisNZ

06-19-2018 09:51 PM - edited 06-19-2018 09:52 PM

Yes but how would I check for the "fac" of each subject within the data set? The variable M should update after each subject.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to azt5173

a month ago

The data step executes for each observation. This works:

```
data m12;
set data;
M = catt('M', FAC, TREATMENT);
run;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ChrisNZ

a month ago

Okay, thank you I will try it.