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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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