In reply to Bhavin Vala.

Thanks Bhavin for raising this performance concern, I had never thought evaluating expression dynamically for big data :). When we process dataset with large rows, we do need to take consideration of computational complexity.
It is quite good that you already use random access to read the dataset, it would sigificantly improve the performance. I tried 3 types imprvoment, and it turns out that even we can improve the _n_ condition with "if-else if" and "select-when", the output is still not as good as "random acecss" solution. The computational complexity is listed as below:
Type Complexity Time (20K rows)
if: N^2 43s
if/else if: N^2/2 32s
select-when:N^2/2 29s
random access: N 17s

Please note that the performance is also related to the code lines dynamically generated to I/O from large data, so turn off some sas options will be helpful.
option nomprint nomlogic nosource nonotes;