Much depends on what your ultimate goal is. I personally don't like to think too hard. I see that that DATAFIELD looks like a SAS Variable List that can be used in a array statement. If I let SAS create an ARRAY with the list I can use DIM to determine the number of elements.