title: Finding minimum/oldest create date for each subscriber in two different formats SAS
body: <p>I have a dataset of call logs made to a group of subscribers called multiple times, with each call attempt on a new row. I need to analyze some data based on when the first contact was made to the subscriber, but I'm having trouble pulling the minimum date of contact. I've tried a few things, but the only successful output I created simply output the create date (which is the variable I need to get the minimum of for each subscriber's set of calls) that was already linked to the line, not the smallest create date in the dataset for that subscriber.</p>
  <p>My ideal outcome would look like this (where min_date/min_month are the variables I'm trying to create):</p>
  <p>Subscriber ID  | Create Date | Min_date | Min_month <br /></p>
  <p>123456     | 01Jan2020 | 01Jan2020 | Jan2020 <br />
  123456     | 05Mar2020 | 01Jan2020 | Jan2020 <br /></p>
  <p>I've also had some issues with the output format. When I did get output, I get dates formatted in some sort of sequential numeric code? For example, I will get something like '22095' instead of any sort of actual date.</p>
  <p>The code I'm using to pull a minimum date:</p>
  <pre><code>
  create table  min_dates as 
  
  select 
  sub_id,
  min2.min_date2
  
  
  from (select 'Subscriber ID'n as sub_id, min('Create Date'n) as  min_date2 from work.min) as min2
  
  inner join work.min as min1 on min1.'Subscriber ID'n = min2.sub_id;
  
  
  
  quit;
  </code></pre>
  <p>I think this might be working but I cannot really tell due to the formatting issues. When I re-join this subtable back to the main data pull at the end of my code all of the values are also missing. I need two more things out of this code if it is correct:</p>
  <ul>
  <li>The same minimum date broken into a new column with just the month and year</li>
  <li>The min_date formatted correctly into a readable date (I don't have a need for any particular date format as long as it is actually a date)</li>
  </ul>
  <p>But if it is wrong and is simply giving me the date on the same row, I need to fix that too.</p>
  <p>Any help is appreciated.</p>