title: What is the SAS format and informat for "mm/dd/yyyy hh:mm:ss"?
body: <h1>The Question</h1>
  
  <p>Please is there a built-in SAS format and informat for datetime in <code>mm/dd/yyyy hh:mm:ss</code>?  For example:</p>
  
  <p><code>06/25/2015 03:02:01</code>  (June 25th 2015, 3 o'clock 2 minute 1 second).</p>
  
  <h1>The Background</h1>
  
  <p>I am trying to parse a CSV flatfile to a SAS dataset in which a datetime column is currently presented in <code>mm/dd/yyyy hh:mi:ss</code> format. I usually would just read it as a string, and then use the <code>substr()</code> function to pick out the date and time parts (as strings), use informat to resolve the SAS date and time (as numbers), and then combine them together to form a SAS datetime (as numbers). I am guessing there could be a cleaner way to do this and therefore am curious if there is already a built-in SAS datetime for <code>mm/dd/yyyy hh:mm:ss</code> which will enable me to read this in one-parse, like this:</p>
  
  <pre><code>data test;
      infile "c:\temp\test.csv" dlm=',' missover;
      input 
          dtvar : &lt;the datetime format for mm/dd/yyyy hh:mm:ss&gt;.
          var1 $
          var2 $
          ;
      format dtvar DATETIME19.;
  run;
  </code></pre>
  
  <p>I have been doing lots of Google searches on this and no luck. Would be very grateful for this!</p>
  
  <h1>EDIT / Update (on additional research efforts and findings)</h1>
  
  <p>Following the generous forum responses I have performed a comparison between the bespoke (home-made) format <code>mdyhms</code> and the SAS built-in format <code>mdyampm</code>. </p>
  
  <p>The success factors are:</p>
  
  <ul>
  <li>Format case: be able to display 1748351045 as "06/25/2015 03:02:01"</li>
  <li>Informat case: be able to convert "06/25/2015 03:02:01" to 1748351045</li>
  </ul>
  
  <p>The bespoke format <code>mdyhms</code> looks like this:</p>
  
  <pre><code>proc format;
    picture mdyhms
    other = '%0m/%0d/%Y %0H:%0M:%0S' (datatype=datetime);
  run;
  </code></pre>
  
  <p>The comparison exercise below reveals some interesting observations:</p>
  
  <ul>
  <li>Format case: the bespoke format <code>mdyhms</code> is the winner.</li>
  <li>Informat case: the built-in format <code>mdyampm</code> is the winner.</li>
  </ul>
  
  <p>Now the comparison exercise...</p>
  
  <h2>Format Case</h2>
  
  <pre><code>*** bespoke mdyhms as a format (Winner);
  data try_format_mdyhms;
    x = "25JUN2015:03:02:01"dt;  /* 1750820521 */
    put x;                       /* 1750820521 */
    put x:mdyhms.;               /* 06/25/2015 03:02:01 */
  run;
  
  *** built-in mdyampm as a format (Loser);
  data try_format_mdyampm;
    x = "25JUN2015:03:02:01"dt;  
    put x;                       /* 1750820521 */
    put x:mdyampm.;              /* 6/25/2015  3:02 AM */
  run;
  </code></pre>
  
  <h2>Informat Case</h2>
  
  <pre><code>*** bespoke mdyhms as an informat (Loser);
  data try_informat_mdyhms;
    x = input("06/25/2015 03:02:01",mdyhms.);  /* informat fail (error) */
    put x; 
  run;
  
  *** built-in mdyampm as an informat (Winner);
  data try_informat_mdyampm;
    x = input("06/25/2015 03:02:01",mdyampm.);  /* 1750820521 */
    put x;                                      /* 1750820521 */
  run;
  </code></pre>
  
  <h1>Next step:</h1>
  
  <p>Are there any built-in (and/or bespoke) formats that will enable BOTH format and informat as per following success factors:</p>
  
  <ul>
  <li>Format case: be able to display 1748351045 as "06/25/2015 03:02:01"</li>
  <li>Informat case: be able to convert "06/25/2015 03:02:01" to 1748351045</li>
  </ul>
  
  <p>(the bespoke <code>mdyhms</code> and built-in <code>mdyampm</code> seem to be able to achieve one of the two, but not both). Or have I missed anything?</p>