Solved
New Contributor
Posts: 3

# How does SET INSET(OBS=n) work with a following WHERE statement?

```data outset;
set inset (obs=10);
where X=Y;```

Does this code logic mean:

Select the first 10 observations from inset and select WHERE X=Y from those 10.

OR

Select observations from inset and apply WHERE X=Y until 10 observations have been selected.

I assume the former but there is an ambiguous question/solution in the Base Programming 2 course that is throwing me off:

3. Read only the first 10 observations satisfying the WHERE statement.

```set orion.order_fact (obs=10);
where year(Order_Date)=2009;```

Accepted Solutions
Solution
‎04-05-2018 08:35 AM
Super User
Posts: 2,516

## Re: How does SET INSET(OBS=n) work with a following WHERE statement?

This: Select observations from inset and apply WHERE X=Y until 10 observations have been selected.

If you have access to SAS, it is a lot faster to test yourself than to ask here, and a much better way to learn as well, by doing.

All Replies
Solution
‎04-05-2018 08:35 AM
Super User
Posts: 2,516

## Re: How does SET INSET(OBS=n) work with a following WHERE statement?

This: Select observations from inset and apply WHERE X=Y until 10 observations have been selected.

If you have access to SAS, it is a lot faster to test yourself than to ask here, and a much better way to learn as well, by doing.

Posts: 5,626

## Re: How does SET INSET(OBS=n) work with a following WHERE statement?

Compare test1 with test2

``````data test1;
set sashelp.class(obs=1);
where name = "John";
run;

proc print data=test1; run;

data test2;
set sashelp.class(obs=1);
run;

proc print data=test2; run;``````

If the WHERE condition was applied after the observation count, test1 would be empty.

PG
Super User
Posts: 10,600

## Re: How does SET INSET(OBS=n) work with a following WHERE statement?

See Maxim 4.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.