<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: datetime format issue in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333209#M17953</link>
    <description>&lt;P&gt;You can do this (sort of) with a picture format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture myDt 
other = '%0m/%0d/%Y:%0H:%0M:%0S.000000' (datatype=datetime);
run;

data _NULL_;
   timestamp = '17JAN2017:18:36:05'dt;
   put timestamp =  myDt26.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Feb 2017 22:45:38 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-02-15T22:45:38Z</dc:date>
    <item>
      <title>datetime format issue</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333156#M17950</link>
      <description>&lt;P&gt;data test(keep=mydate);&lt;/P&gt;
&lt;P&gt;set test2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;sample data&lt;/P&gt;
&lt;P&gt;mydate&lt;/P&gt;
&lt;P&gt;17JAN2017:18:36:00.000000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish to display mydate as&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;01/17/2017 :18:36:00.000000&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using mmddyy10 hh:mm:ss and get syntax error.&amp;nbsp; By default it displays in date9 plus the hr min sec interval.&amp;nbsp; Just want to display as mmddyy format as above in bold&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333156#M17950</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2017-02-15T20:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: datetime format issue</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333172#M17951</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   timestamp = '17JAN2017:18:36:00'dt;
   format timestamp datetime26.;
   put timestamp=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 21:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333172#M17951</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-15T21:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: datetime format issue</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333209#M17953</link>
      <description>&lt;P&gt;You can do this (sort of) with a picture format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture myDt 
other = '%0m/%0d/%Y:%0H:%0M:%0S.000000' (datatype=datetime);
run;

data _NULL_;
   timestamp = '17JAN2017:18:36:05'dt;
   put timestamp =  myDt26.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 22:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333209#M17953</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-02-15T22:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: datetime format issue</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333213#M17954</link>
      <description>&lt;P&gt;I don't think that's what the op wants.&amp;nbsp; In particular, it seems they want this format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mm/dd/yyyy :hh:mm:ss.ffffff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get close to this by making a custom format via the PICTURE statement in proc format.&amp;nbsp; It has the "datatype=datetime" option, which tells it to obey datetime-related directives (the % signed elements below):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Sasfont"&gt;format&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; picture&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; mydtfmt &lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;low-high=&lt;/FONT&gt;&lt;FONT color="#800080" face="Sasfont"&gt;'%Y%0m%0d %0H:%0M:%0S'&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;datatype&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;=datetime) ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&amp;nbsp;dt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;"17jan2017:18:36:00.300000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; put&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; dt=&lt;/FONT&gt;&lt;FONT color="#008080" face="Sasfont"&gt;mydtfmt26.6&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, this&amp;nbsp;generates a value with no decimals (because there are no datetime directives for fractions of a second):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; dt=20170117 18:36:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you have to make a text variable using the mydtfmt format above concatenated with the fractional component, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  picture mydtfmt 
    low-high='%Y%0m%0d %0H:%0M:%0S' (datatype=datetime)   ;
run;
     
data _null_;
  dt="17jan2017:18:36:00.300000"dt;

  fraction=substr(cats(mod(dt,1),'000000'),2,7) ;
  date_text=put(dt,mydtfmt20.)||fraction;
  put date_text=;

  /** or more compactly (without intermediate variable "fraction" .... **/
  date_text2=put(dt,mydtfmt20.)||substr(cats(mod(dt,1),'000000'),2,7);
  put date_text2=;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 22:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/datetime-format-issue/m-p/333213#M17954</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-15T22:57:04Z</dc:date>
    </item>
  </channel>
</rss>

