There are at least 2 errors in this code:
1) %NameList = ... is not a valid syntax. It should be %let NameList=...;
2) PROC IMPORT OUT=out.&NAME_&qtr line does not have a . separator for macro variable &NAME, therefore macro compiler thinks it's macro variable &NAME_ (as _ is a valid character for a macro variable name) and obviously cannot find it.
Using %QUOTE() macro function is correct for masking commas when passing the comma-separated value into the %scan() macro function. For more details and in-depth discussion see my recent blog post Passing comma-delimited values into SAS macros and macro functions
... View more