Longduration,
First, a question about test.database. What does it really look like? From your example, it might have three records which contain 3 values separated by commas, of it might have three records, each with a value and, possibly, a comma. Not clear.
From your original post, I had thought that test.database looked like:
[pre]
data test.database;
informat variables $10.;
input variables &;
datalines;
A B C
E
G H
;
run;
In order to provide a solution, we have to know for sure what that file actually looks like.
Art
> Apologies if my problem wasn't clear. Hopefully this
> is better:
>
> ------------------------------------------------------
> ----------------------------------------------------
> Original file that is to be filtered by column "TYPE"
> using the variables in TEST.DATABASE:
>
> TEST.ORIGINAL
>
> Column1 Column2 TYPE Column4
> x x A x
> x x G x
> x x B x
> x x D x
> x x C x
>
> ------------------------------------------------------
> ----------------------------------------------------
> File with variables that are used to filter the
> column "TYPE" in TEST.ORIGINAL:
>
> TEST.DATABASE
>
> Variables
> A,
> B,
> C,
>
> ------------------------------------------------------
> ----------------------------------------------------
> Resulting in a file with observations only where
> "TYPE" contains the variables specified earlier:
>
> TEST.FILTERED
>
> Column1, Column2, TYPE, Column3
> x,x,A,x
> x,x,B,x
> x,x,C,x
>
> ------------------------------------------------------
> ----------------------------------------------------
>
> The following code solves this except it produces an
> individual file (TEST.A
> TEST.B and TEST.C for each variable and not a single
> file as I had originally wanted (DATA.FILTERED):
>
> ------------------------------------------------------
> ----------------------------------------------------
>
> PROC SQL
> SELECT COUNT (VARIABLES)
> INTO :n
> FROM TEST.DATABASE;
> QUIT;
>
> %MACRO FORUM;
>
> %DO i=1 %TO &n;
> DATA TEST.&&VARIABLES&i;
> SET TEST.ORIGINAL;
> IF TYPE="&&VARIABLES&i";
> RUN;
>
> %END;
> %MEND;
> %FORUM;
>
> ------------------------------------------------------
> ----------------------------------------------------
>
> Art, if you have alternative solution I would still
> appreciate reading it.
>
> Thanks