In reply to Olle.

Thank you, Olle, for sharing your approach. You, however, solve slightly different problem. Yes, your code will generate either a numeric value or an unquoted character string through %scan. But I was mimicking do-loop with listed values; for listed character values they need to be quoted. Your unquoted character string can be used as variable name, but not as a character value.