Re: proc sql in do loop in macro with %eval

You cannot do that. my_numeric_column is part of the Base SAS language, i.e. its in a dataset. &i and the loop are part of the macro language. At the time the macro pre-processor is working, i.e. when it is resolving the macro code, there is no dataset available - so the variable does not exist, nor does the proc sql. That is all later on at compile time. The macro pre-processor is there to expand on the text given using its rules. Give example test data in a datastep of what you want have and example of what you want to achieve. For example, you could use arrays:

Re: proc sql in do loop in macro with %eval

You cannot create variables dynamically on the contents of other variables while a proc sql or a data step is running. The structure of the datasets is set while the step is compiled, and cannot change thereafter.

This would also be physically impossible, as the structure of a SAS dataset is written into its header page and determines the layout of all following records, and therefore can't change while the dataset is being written.