title: Checking to see if a dataset exists
body: <p>I've just finished the main macro for a project that I'm on. It generates a line to enter into another table. So, my next step is to write another macro that calls this one. One of the arguments for this next macro is the name of the dataset in which to insert this new observation, which leads to my question...</p>
  
  <p>I'd like for my next macro to check and see if the named dataset exists. If so, it will insert the new calculated line into the dataset. If it dose not yet exist, I'd like to save the new line as a dataset with this name. </p>
  
  <p>To get a little bit more concrete, let's suppose I have the macro
  %calculate_for(ARG1, ARG2, ARG3) that creates a single-observation dataset NEXT_LINE. I want to write a macro that does something like:</p>
  
  <pre><code>%macro do_for(ARG1, ARG2, ARG3, DATASET_NAME);
  
    %calculate_for(&amp;ARG1, &amp;ARG2, &amp;ARG3)
  
    {if DATASET_NAME exists then do:}
    data &amp;DATASET_NAME;
      set &amp;DATASET_NAME
          NEXT_LINE;
      run;
  
    {if DATASET_NAME doesn't exist yet then do:}
    data &amp;DATASET_NAME;
      set NEXT_LINE;
      run;
  %mend;
  </code></pre>
  
  <p>How might I go about doing this in SAS?</p>