If we assume this is coming from your other question (About reading in a .CSV and keeping only a few columns), there is an interesting solution, assuming your data isn't too wild and crazy.
First, a few notes. You can't conditionally KEEP variables with just data step code.
if x>1 then keep y;
That doesn't work. It will always keep y. The keep/drop/rename (and some other statements, called compile-time statements, are not allowed to depend on the data: their effect is defined during the compilation of the data step. This goes into relatively complex SAS details, but the long and short of it is, you can't use Drop, Keep, Rename conditionally without dipping into the macro language.
Second, note that if you know the names of the columns you want to keep, just put them in a keep statement. Iterating through an array isn't going to help you here, unless you're trying to do it conditionally by some sort of data value, which as above isn't directly possible.
However, if you're reading in from a CSV file (or any other input method), you can do something not all that different, which will do exactly what you want it to, and allow you to effectively read in a delimited file by selecting specific columns. I posted that part as an answer to the master duplicate here from your other question, as it's really more appropriate there (given your question here doesn't reference CSV files or anything else like that), but I suspect it would be useful.