How can it be running on tables that do not exist? This bit of code you provided should return a list of only existing tables:
CREATE TABLE SAS_Table_Del AS SELECT * FROM CONNECTION TO TERADATA ( SELECT Output_Tbl_Nm , ROW_NUMBER() OVER ( ORDER BY 1) as record_id FROM <TD Database>.<TD Control Table>;)
Also, please code using some readability format, i.e. same casing, indentations and make sure you post code into a code block in the post (use the {i} or sas symbol above where you post) etc. your code is very hard to look at, example:
data _null_;
set sas_table_del end=last;
if _n_=1 then call execute ('proc sql noerrorstop;
connect to teradata(tdpid="&tdpid." user="&tduid." pass="&tdpass" query_band="&queryband.");');
call execute ('EXECUTE(DROP TABLE ZMKTTO_MCMADHOC.'||strip(Output_Tbl_Nm)||') BY TERADATA;');
call execute ('EXECUTE (COMMIT WORK) BY TERADATA;');
call execute('EXECUTE(DELETE FROM ZMKTTO_MCMADHOC.DB_MNGT_CTL_MCM_NEW where OUTPUT_TBL_NM='''||strip(Output_Tbl_Nm)||''' and PRCS_FLG='''||'C'||''') BY TERADATA;');
call execute ('EXECUTE (COMMIT WORK) BY TERADATA;');
if last then call execute('disconnect from teradata; quit;');
run;
... View more