Asked • 04/19/19

Limiting results in PROC SQL?

I am trying to use PROC SQL to query a DB2 table with hundreds of millions of records. During the development stage, I want to run my query on an arbitrarily small subset of those records (say, 1000). I've tried using INOBS to limit the observations, but I believe that this parameter is simply limiting the number of records which SAS is processing. I want SAS to only fetch an arbitrary number of records from the database (and then process all of them). If I were writing a SQL query myself, I would simply use `SELECT * FROM x FETCH FIRST 1000 ROWS ONLY ...` (the equivalent of `SELECT TOP 1000 * FROM x` in SQL Server). But PROC SQL doesn't seem to have any option like this. It's taking an extremely long time to fetch the records. The question: How can I instruct SAS to arbitrarily limit the number of records to **return from the database**. I've read that PROC SQL uses ANSI SQL, which doesn't have any specification for a row limiting keyword. Perhaps SAS didn't feel like making the effort to translate its SQL syntax to vendor-specific keywords? Is there no work around?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.