title: Which is preferred for mapping values: reusing mapping functions OR building reference tables to do lookups?
body: <h1>Which is preferred for mapping values: reusing mapping functions OR building reference tables to do lookups?</h1>
  <p>This is a very general high-level question, which, <em>I believe</em> is mostly language-independent. For the example, I will use <code>SAS</code>, but I also would like to know how people feel about this in <code>R</code> and <code>python</code>.</p>
  <p>I am on a team that likes to use mapping functions to take an input and generate some output, usually in a one-to-one manner. For example, here is some modified SAS code that shows what my team typically does:</p>
  <pre><code>proc fcmp;
      function mapFunction($ input);
          output = .;
          if input= &quot;Day zero&quot; then output= 0;
              else if input = &quot;Day one&quot; then output = 1;
              else if input = &quot;Day two&quot; then output = 2;
          return(output);
      endsub;
  run;
  </code></pre>
  <p>The team would then use <code>mapFunction</code> in multiple other programs when mapping needs to be done.</p>
  <p><strong>This goes against my instinct.</strong> My instinct would be to use the mapping function once to generate a set of key:value pairs or a dictionary or two-column table and thereafter use lookup/indexing/joining/merging operations to refer to the table.</p>
  <p>I have a hard time explaining why this is my instinct, but it is. It <em>feels</em> better to have a reference table instead of calling a custom function repeatedly. However, I don't trust my <em>feelings</em>, and I'd like to hear from others to see if I can rationalize one technique over the other.</p>
  <h3>Can someone provide arguments/counter-arguments to support one technique or the other?</h3>
  <p>Thank you!</p>