Help using Base SAS procedures

Output dataset has x amount or records

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Output dataset has x amount or records

, HI,

I will like to create a query using PROC SQL or a DATA Step and have SAS gave me an output dataset with only 10 records.

For example, I have a dataset named 'have' with 1 million records and I am running an certain functions ans if/then statements.  I am limiting my output if certain conditions are met.

Can I limit processing based on the number of records present in the output dataset?  When output dataset "want" has 10 observations then stop processing and output.

Thank you for your help;


Accepted Solutions
Solution
‎07-27-2015 12:57 PM
Super User
Posts: 17,912

Re: Output dataset has x amount or records

I don't think there's a way to control the number of outobs in a data step.

You can use OBS= option, either globally through an option statement or as a dataset option to limit the input data size. If your if/then options don't elimininate observations or control output this should be fine.

You can use OUTOBS in SQL to limit the number of output obs.

If the purpose is testing for development, I tend to use the global OBS= option and then reset it when I'm done.

View solution in original post


All Replies
Super Contributor
Posts: 275

Re: Output dataset has x amount or records

proc sql inobs=10;

select * from sashelp.class;

quit;

data class;

  set sashelp.class(obs=10);

run;

Valued Guide
Posts: 858

Re: Output dataset has x amount or records

You'll change the 5 to 10 for your purpose but this will work:

data have;

infile cards dsd;

input input;

cards;

1

2

3

4

5

6

7

8

9

10

;

options obs=5;

data want;

set have;

run;

proc sql outobs=5;

create table want2 as

select * from have;

Solution
‎07-27-2015 12:57 PM
Super User
Posts: 17,912

Re: Output dataset has x amount or records

I don't think there's a way to control the number of outobs in a data step.

You can use OBS= option, either globally through an option statement or as a dataset option to limit the input data size. If your if/then options don't elimininate observations or control output this should be fine.

You can use OUTOBS in SQL to limit the number of output obs.

If the purpose is testing for development, I tend to use the global OBS= option and then reset it when I'm done.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 263 views
  • 0 likes
  • 4 in conversation