If Excel is your final target, and you want your code to be as flexible as possible, I recommend to use proc export as @Astounding already suggested:
proc sql;
connect to db2 (SSID = DB2Y);
create table WORK.ABC as
select * from connection to db2 (
SELECT
------------
);
%put sqlXRC = &sqlXRC.;
%put sqlXMSG = &sqlXMSG.;
disconnect from db2;
quit;
proc export
data=WORK.ABC
outfile=SAVE01
dbms=csv
replace
;
run;
You might even be able to use an Excel destination as dbms, but csv is provided in Base SAS without additional licenses.
... View more