BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ismahero2
Obsidian | Level 7

, 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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

3 REPLIES 3
slchen
Lapis Lazuli | Level 10

proc sql inobs=10;

select * from sashelp.class;

quit;

data class;

  set sashelp.class(obs=10);

run;

Steelers_In_DC
Barite | Level 11

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;

Reeza
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1733 views
  • 0 likes
  • 4 in conversation