Reduced proc sql runtime?

in other environments, if you just want to look at the top few results, you can use

select top 5 *
where rownum < 6
OBS = 5

but is there a way to do that in a SAS Proc sql statement? Where you just want to look at the results of your proc sql? I’ve seen outobs=10 , but i don’t necessarily think that stops the compiling of all of your results, but instead runs the entire script, then shows only the top 10 or whatever results. What i really want though is to have it stop running as soon as there are 10 observations and show that.

Any ideas?

This is what chatgpt tells me, but I’m not a PROC SQL expert so it might be hogwash:

    SELECT TOP 10 *
    FROM YourTable;



+1 for inobs=

I just wanted to confirm that I did know that this was a SAS question.

Unfortunately, I don’t know how to code in SAS.

This is relatively common amongst their employees it seems.

1 Like

We just work here okay?


note that “TOP 10” will still run the entire query and return the listed item.

You can use a limit statement at the end to get the number of rows:

SQL statement
limit 10