turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Difference between IF and WHERE statement of outpu...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-15-2016 03:59 AM

The difference between IF and WHERE statment is - IF statement applies filter after reading data in PDV and where applies even before reading in PDV.

Suppose where statement written in output dataset as shown below then what is the difference.

data new_1 (**where= (x=2)**);

input x;

t=x;

cards;

1

2

3

4

;

data new_2;

input x;**if x=2 ;**

cards;

1

2

3

4

;

Accepted Solutions

Solution

06-15-2016
04:08 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RahulG

06-15-2016 04:04 AM

In your case, there is no difference.

But the subsetting if is part of data step logic and allows you to exit from a data step iteration prematurely; the where option in the output dataset does not influence data step logic, and therefore all data step iterations will be completed, even if semantically unnecessary.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

All Replies

Solution

06-15-2016
04:08 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RahulG

06-15-2016 04:04 AM

In your case, there is no difference.

But the subsetting if is part of data step logic and allows you to exit from a data step iteration prematurely; the where option in the output dataset does not influence data step logic, and therefore all data step iterations will be completed, even if semantically unnecessary.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code