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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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