Hi:
Just a comment to clarify. Technicallly, you could not code a PROC SQL step -inside- a DATA step program. So, that can make the CALL EXECUTE solution seem confusing, because the type of the CALL (EXECUTE) implies that the called code is being executed from within the DATA step. It really should be named the
"PUT-IN-THE-STACK-TO" EXECUTE call routine....but CALL EXECUTE is so much more brief.
But, all that's really happening is that any macro call generated inside a DATA step with CALL EXECUTE is placed into a holding area or stack. None of the code, let me repeat, NONE of the code, is executed while the DATA step is executing. The code (macro call with dataset variable values) is placed into the stack. THEN, as soon as the DATA step program is over and the step boundary has been reached, all the code that's been placed in the stack starts to execute. This means you can build your macro call using dataset variable values, but that the generated macro call will not actually run until the DATA step program ends.
cynthia