BookmarkSubscribeRSS Feed
kentlewan
Fluorite | Level 6

I am posting a (hopefully correct) response for "How to select first few records to test the Proc SQL", which has a non-working solution, and is locked:

https://communities.sas.com/t5/SAS-Programming/How-to-select-first-few-records-to-test-the-Proc-sql/...

 

@LAP @srinidelite @SimonJF  @ChrisNZ @Reeza @LinusH  the solution I came up with is:

 

Proc Sql outobs=10;
create table TESTRESULT as
select COL1, COL2
from YOURLIB.YOURTABLE

where YOURFILTERS;
quit;

 

If there is no error in the SQL statement, this will return 10 records and produce &syscc = 4 / &sqlrc = 4 (warning.) 

 

You need to code to check SYSCC/SQLRC, if you are checking for warnings or errors.

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Using option OUTOBS= is the chosen solution. As I see it, this post brings no value to a topic closed 12 years ago.

 

kentlewan
Fluorite | Level 6
Not disagreeing with solution provided in 2008. However, the experts provided no sample code to allow users to copy. Unclear where OUTOBS= is supposed to go. That is why I've reposted it.
ChrisNZ
Tourmaline | Level 20

> Unclear where OUTOBS= is supposed to go.

 

Really?

Here is first line of the chosen reply:

 

you can use inobs= or outobs= option on the PROC SQL statement.

kentlewan
Fluorite | Level 6
What's clear to you might not be as clear to newbies.
Why not wait and see if this post gets any likes.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1331 views
  • 3 likes
  • 2 in conversation