In reply to Aaron Rodriguez.

You could check the macro variable that PROC HTTP updates to make sure your URL is working. As you iterate through and find a page that returns anything but an HTTP 200 code, maybe that's an indicator you're done.

Or, look at a page that results from going beyond the page boundary, and add code in your program to detect that. It's a messy business!