I believe it is this step that is not allowed in a stored procedure.
This is an excerpt from the dynamic SQL:
INSERT INTO gttBirthdate
SELECT B.plan, B.membernumber, A.birthdate
FROM ' || tblsourceforbirthdates || ' AS A
INNER JOIN ' || tblINPUT || ' AS B
ON A.planId = B.planID AND A.membernumber = B.membernumber
WHERE A.birthdate >= DATE''1900-01-01''
I believe it is this step that is not allowed in a stored procedure.
This is an excerpt from the dynamic SQL: