If I read the macro code you've posted right then %qsysfunc(dread(&did,&i)) will return the source file name with suffix.
You just need to parse out the name without suffix. Below code is untested and will only work for source file names without a second dot in the name.
%let name2=%qscan(%qsysfunc(dread(&did,&i)),-2,.);
So you could change your code to something like:
.....out=work.&name2
But: This will only work if your external files comply with SAS naming standards.
Else you will either need something ugly like:
.....out=work."%sysfunc(substrn(&name2,1,32))"n
...or you need to pre-process &name and ensure/convert it to a SAS compliant table name.
Alternatively add the source file name as label
.....out=dsn&cnt(label="&name2")
....or with suffix included
.....out=dsn&cnt(label="%qsysfunc(dread(&did,&i))")
... View more