Sorry, but i don't understand the problem, too.
I would remove all macro statements and verify that the program does, what it should do. Your macro-variables should not start with an underscore, some automatic variables, like _ClientProjectPath, use the underscore to identify them as automatic variables.
So the data step would look like
data customer_details;
set work.installation;
where Contract = 'Y' AND Colour in ('Red', 'Orange', 'Blue')
and contract_date_start="01Mar2022"d and contract_date_end="31Aug2022"d;
run;
Now the export:
proc export data= work.customer_details dbms= xlsx file= "PATH/customer_details.xlsx" replace;
run;
Why do you want a macro at all?
Note: code is untested.
... View more