Hi there.
Can anyone come up with a bit of code which would achive the following:
I have a dataset which contains 44 variables.
MRPOLICY KEY COMCOM1 COMCOM2.......COMCOM42
I need to search through all the COMCOM variables (1 to 42) for a certain string say 'SINGLE';
I can code the longway for this by doing 42 where/or statements like.
WHERE COMCOM1 ? 'STRING' or
WHERE COMCOM2 ? 'STRING' or...
There must be an easier way.
I have been toying with macro variables and do loops but my efforts have amounted to zilch.
Here is some of my effort so far. This obviously does not work.
data test3;
set AS.TEST2;
%let i = 1;
do;
%let i = (&i+1);
where comcom&i ? 'SINGLE';
if &i = 42 then goto out;
end;
out:;
run;
Can anyone help?
Cheers,
Chris....
Can anyone come up with a bit of code which would achive the following:
I have a dataset which contains 44 variables.
MRPOLICY KEY COMCOM1 COMCOM2.......COMCOM42
I need to search through all the COMCOM variables (1 to 42) for a certain string say 'SINGLE';
I can code the longway for this by doing 42 where/or statements like.
WHERE COMCOM1 ? 'STRING' or
WHERE COMCOM2 ? 'STRING' or...
There must be an easier way.
I have been toying with macro variables and do loops but my efforts have amounted to zilch.
Here is some of my effort so far. This obviously does not work.
data test3;
set AS.TEST2;
%let i = 1;
do;
%let i = (&i+1);
where comcom&i ? 'SINGLE';
if &i = 42 then goto out;
end;
out:;
run;
Can anyone help?
Cheers,
Chris....