SAS: Combine YEAR and MONTH data into a single mm/dd/yyyy date without changing types
<p><strong>Question:</strong> How do I combine YEAR and MONTH data into a single mm/dd/yyyy date without converting from numeric to character types?</p>

<hr>

<p>I have date data which needs to be read into SAS.  It comes in two columns, YEAR and MONTH.  The data looks similar to this:</p>

<pre><code> YEAR MONTH
 2012 1
 2012 1
 2013 10
 2012 2
 2014 7
</code></pre>

<p>The data must be stored in mm/dd/yyyy format.  For example, YEAR = 2013 and MONTH = 10 corresponds to 10/01/2013.</p>

<p>I have accomplished this via:</p>

<pre><code>if month = 1 then
  date = input(compress("01/01/"||year),mmddyy10.);
else if month = 2 then
  date = input(compress("02/01/"||year),mmddyy10.);
...
</code></pre>

<p>However, the log gives the following note:</p>

<blockquote>
  <p>NOTE: Numeric values have been converted to character values at the
  places given by:
        (Line):(Column).</p>
</blockquote>

<p>I understand that this is being done because SAS stores dates as numeric values since January 1, 1960.  The Compress function returns a character value.  Thus, the numeric data is being coerced into a character type.</p>

<p>While the above code sufficiently solves my problem, the note implies that date formatting should not be handled in this way (via type conversion). </p>