Where is &nobs assigned - also, is it intentional that you have reference to &i outside your %DO loop? Lastly, suggest adding this code to help SAS generate the most diagnostics output for your desk-checking with SAS compilation:
OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT /* MLOGIC */;
And, with the above code added, suggest the OP re-post a reply with the SAS-generated log output revealed, not just the code-piece -- presuming the problem is still not solved with additional log diagnostics info.
Scott Barry
SBBWorks, Inc.