- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
hi,
I have a question about the use of prxmatch and arrays.
I have a list with multiple different therapies (treat1-treat15). I want to select all chemotherapies from this list and combine different types of chemo that are given as combination therapy. I wrote the syntax below. This works for comparing treat{i} and treat{i+1}, but I also want to compare treat{i} with treat{i+2}, treat{i+3} etc. And preferably also compare treat{i} with treat{i+1} and treat {i+3} at the same time, as there might be up to three or four chemotherapies that need to be combined. Is there an easy way to do this?
%let chemo = XY40|BC50|XA60|ZL90|OX15|MZ78;
data twee;
set een;
array treat15} $ treat1 - treat15;
array treat_dat{15} treat_dat1 - treat_dat15;
array CT{15} CT1-CT15;
array CT_dat{15} CT_dat1-CT_dat15;
CT=0;
do i=1 to 15;
if prxmatch("m/&chemo/i", treat{i})>0 and prxmatch("m/&chemo/i", treat{i+1})>0
and treat_dat{i}=treat_dat{i+1} then do;
if treat{i}=XY40 and treat{i+1}=BC50 then do; CT{i}=OX15; CT_dat{i}=treat_dat{i}; end;
if treat{i}=XY40 and treat{i+1}=XA60 then do; CT{i}=MZ78; CT_dat{i}=treat_dat{i}; end;
end;
run;
Thanks in advance!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Without sample data it is hard to get a sense of what you are doing.
But it sounds like you just need another DO loop.
DO I=1 to 15 ;
DO J=I+1 to 15;
Now you can compare the Ith variable in the array to the Jth variable in the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Without sample data it is hard to get a sense of what you are doing.
But it sounds like you just need another DO loop.
DO I=1 to 15 ;
DO J=I+1 to 15;
Now you can compare the Ith variable in the array to the Jth variable in the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You likely will need a much larger OUTPUT array. Consider comparing 4 items:
A B C D
The pairwise comparisons are
AB AC AD BC BD CD
The function comb will give the number of elements you may need:
data example; needed = comb(15,2); run;
which will yield 105 combinations taken 2 at a time. Do you need to consider 3 at a time? That would be 455.
And if the ORDER encountered is important, where AB is different from BA in my starting discussion, then you need Permutations with the function Perm to get the number of permutations (210 for 15 taken 2 at time).
Your comparisons also will fail. To compare values:if treat{i}=XY40 is going to look for a variable named XY40. You should be using quoted literal values:
if treat{i}="XY40"
You might want to look at the combinatorial functions ALLCOMB or Call Allcomb.