title: How to iteratively run a SAS procedure with different subsets of data?
body: <p>I would like to repeatedly run <code>PROC REG</code> with different subsets of an existing SAS dataset.  Here's a simple example dataset:</p>
  
  <pre><code>DATA data_main;
    input trt depth year response;
    cards;
  1 1 2014 1.1
  1 2 2014 1.2
  2 1 2014 1.3
  2 2 2014 1.4
  1 1 2013 2.2
  1 2 2013 2.4
  2 1 2013 2.6
  2 2 2013 2.8
  ;
  run;
  </code></pre>
  
  <p>For each combination of trt and depth I want to run this procedure, where <code>current_data</code> is the current combination of <code>trt</code> and <code>depth</code>:</p>
  
  <pre><code>PROC REG data = current_data;
      model response = year;
  run;
  </code></pre>
  
  <p>And I want to capture the regression coefficients and p-values for all iterations in one dataset or text file.</p>
  
  <p>The number of levels of input and trt is much greater in my actual dataset, so I'm trying to avoid manually coding each combination.  Can someone explain to me how to do this?</p>