Please place code or log text into a text box. Then we can actually see it in a usable forma and possibly even edit it to correct problems or suggest changes. Open a text box using the </> icon that appears above the message window and the paste any copied text. That has to be simpler than making a picture, especially when it requires multiple pictures to show everything.
You should also show an example of actually calling the macro.
From what I see the problem is most likely to come from something before after the macro call.
You have several places in you macro that may be very hard to debug if something goes a bit awry. You use the same data set name on the Data and Set statement. That means the source data set on the Set statement was completely replaced by the output. So if there is an assignment issue you may no longer have a way to debug the data as the same set has been replaced a couple times in the macro.
... View more