Reputation: 61
I want to execute a query only when a condition is satisfied. The code I want to execute is:
proc sql NOPRINT OUTOBS=1;
%CASE WHEN (&_count_ > 0) THEN
DELETE FROM TABLE T
WHERE T.Period = xxxxxx
END;
quit;
Upvotes: 1
Views: 255
Reputation: 61
i found the solution:
%macro delete_rows();
PROC SQL;
DELETE FROM Table T
WHERE Period=xxxxxx;
QUIT;
%mend;
%macro check_if();
%IF (&nbr_rows > 0) %THEN
%delete_rows();
%mend;
Upvotes: 1
Reputation: 6193
Use IF
instead of CASE
:
proc sql NOPRINT OUTOBS=1;
%IF(&_count_ > 0) %THEN %DO
DELETE FROM TABLE T
WHERE T.Period = xxxxxx
%END;
quit;
Upvotes: 1