SAS did what you asked it to do, remove the spaces between the strings.
Try using CATX() instead.
select catx(' ','data', memname, ';set',catx('.',libname,memname), ';run;')
into :loading_code separated by ' '
If you are copying actual datasets (and not physicalizing views) then just use PROC COPY.
proc copy in=CODING out=work memtype=data;
run;
If you only want some of the members then just generate the list of member names into a macro variable.
select memname into :memlist separated by ' ' ...
And use it to generate a SELECT statement for the PROC COPY step.