And what is the desired output for the process to look like?
You mention another program. What kind " it in values in variable mentined in another program" things are you looking to match? You'll likely have to share at least that second program to know what variables might be. And with variable number of input columns I suspect lots of headaches getting this to align properly.
A "macro" may be possible. I'm not sure that arrays are going to help though as arrays are used to process multiple variables in a single row (observation) in a similar manner (usually).