DATA Step, Macro, Functions and more

Where statement vs where data set option

Reply
Contributor
Posts: 30

Where statement vs where data set option

Is there any processing difference between where statement or where = data set option?

 

Data temp;

set temp1(where = (state = 'NJ');

run;

 

Data temp;

set temp1;

where state = 'NJ';

run;

 

which is better in terms of performance? I know we will get same result but is there any performace improvement if use as datas set option compare to sas statement. 

 

Thanks,

Super User
Posts: 5,516

Re: Where statement vs where data set option

There is no difference in speed, and no difference in how the processing takes place.

 

Differences are in the flexibility when using more than one incoming SAS data set.  Examples:

 

data both;

merge a b;

by state;

where gender='M';

run;

 

Now the WHERE statement applies to both incoming data sets, so GENDER must appear in both.  Compare that with:

 

data both;

merge a (where=(gender='M'))  b (where=(age > 21));

by state;

run;

 

By using WHERE as a data set option, separate conditions can be applied to each incoming DATA set.  A stand-alone WHERE statement would not be possible to accomplish the same task.

Ask a Question
Discussion stats
  • 1 reply
  • 186 views
  • 1 like
  • 2 in conversation