title: Which is faster, where statement or where data set option
body: <p>The question is really straight forward, which one is faster?</p>
  
  <p>Considering we are using data step with two datasets in the set statement and the datasets have the same variables in them. </p>
  
  <p>From What Ive heard and read, if we subset them using the same condition, say date = "10jan2014"d, the result will be exactly the same using the statement above or the following data set option in the two datasets (where=(date="10jan2014"d)). Because the where is executed before anything comes to the PDV.</p>
  
  <p>Is that right?</p>
  
  <p>For better understanding of the question, I created the following code:</p>
  
  <p>Lets say we have these two datasets.</p>
  
  <pre><code>data people1;
  format birth date9.;
  input name $ birth :date9.;
  datalines;
  John 18jan1980
  Mary 20feb1980
  ;
  run;
  
  data people2;
  format birth date9.;
  input name $ birth :date9.;
  datalines;
  Peter 18mar1980
  Judas 18jan1980
  ;
  run;
  </code></pre>
  
  <p>I want to create a new dataset with those two, but only for people with birth date equals to 18jan1980.
  Now I can use the where statement or the where data set option.</p>
  
  <p>Using the where (data set option):</p>
  
  <pre><code>data everybody1;
  set people1 (where=(birth="18jan1980"d))
      people2 (where=(birth="18jan1980"d));
  run;
  </code></pre>
  
  <p>Using the where statement:</p>
  
  <pre><code>data everybody2;
  set people1
      people2;
  where birth="18jan1980"d;
  run;
  </code></pre>
  
  <p>The new datasets now have the exact same output. But whith one is faster?</p>
  
  <p>Thanks.</p>