<?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: Format Datetime to mm/dd/yyy in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420880#M27086</link>
    <description>&lt;P&gt;Thanks Reeza, this worked!&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2017 16:18:57 GMT</pubDate>
    <dc:creator>Dogo23</dc:creator>
    <dc:date>2017-12-13T16:18:57Z</dc:date>
    <item>
      <title>Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420832#M27078</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone explain to me a simple way to format a date with a timestamp to mm/dd/yyy?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently the date field show like this:&lt;STRONG&gt;&amp;nbsp;14NOV2017:17:42:15.000000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to format within the select statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select marketing_id&lt;/P&gt;&lt;P&gt;format (send_date as.....&lt;/P&gt;&lt;P&gt;etc....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420832#M27078</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-13T15:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420834#M27079</link>
      <description>&lt;P&gt;Quick update, I meant to write mm/dd/yyy&lt;STRONG&gt;y&amp;nbsp;&lt;/STRONG&gt;!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420834#M27079</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-13T15:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420837#M27080</link>
      <description>&lt;P&gt;Okay, it looks like the field send_date in your table is the one that's the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First question...is the data coming into your result as numeric or character?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420837#M27080</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-12-13T15:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420839#M27081</link>
      <description>&lt;P&gt;So what you want to format just the date part and use that, or all the datetime?&amp;nbsp; Date is simple:&lt;/P&gt;
&lt;PRE&gt;data want;
  datepartonly=datepart(yourdatetime);
  format datepartonly mmddyy10.;
run;&lt;/PRE&gt;
&lt;P&gt;If its all the datetime, then you may need to create your own picture format.&amp;nbsp; Here are the available formats:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Out of interest, why can you not use the date as is?&amp;nbsp; If anything that is fine, and if you need it for any other purpose (filename for instance) then I would highly recommend using ISO dates which can be sorted correctly.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420839#M27081</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-13T15:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420840#M27082</link>
      <description>Hi Tom,&lt;BR /&gt;&lt;BR /&gt;I looked at the table properties and it appears that it is coming in as a date with a length of 8.</description>
      <pubDate>Wed, 13 Dec 2017 15:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420840#M27082</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-13T15:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420845#M27083</link>
      <description>Hi RW9,&lt;BR /&gt;&lt;BR /&gt;I would need to refrence the table right? I did it like so (shown below) and I get this error: "ERROR: Invalid variable specification, tableau.metadata_match. Variable names of the form X.X must be either FIRST.X or LAST.X."&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;datepartonly=datepart(processed_dttm);&lt;BR /&gt;format datepartonly mmddyy10.&lt;BR /&gt;from table1;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 13 Dec 2017 15:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420845#M27083</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-13T15:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420848#M27084</link>
      <description>&lt;P&gt;Quick update all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a change and ran in like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select marketing_id&lt;/P&gt;&lt;P&gt;send_date as psend_date format mmddyy8.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It technically formatted correctly, but now the date show as protected ("*****") in the output and when I click into the cell, it shows every date 12 12/31/9999 instead of the correct date. Any clue as to why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420848#M27084</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-13T15:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420859#M27085</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@schlotty23 wrote:&lt;BR /&gt;
&lt;P&gt;Quick update all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made a change and ran in like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select marketing_id&lt;/P&gt;
&lt;P&gt;send_date as psend_date format mmddyy8.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It technically formatted correctly, but now the date show as protected ("*****") in the output and when I click into the cell, it shows every date 12 12/31/9999 instead of the correct date. Any clue as to why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have a datetime not a date. To get the date portion only use DATEPART() function or a datetime format. Your also missing the = sign on the FORMAT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that SAS has two variable types, numeric and character. Date is a numeric variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; &lt;BR /&gt;select marketing_id&lt;BR /&gt;Datepart(send_date) as psend_date format =mmddyy8. ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; &lt;BR /&gt;select marketing_id&lt;BR /&gt;send_date as psend_date format=dtdate9.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420859#M27085</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-13T15:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420880#M27086</link>
      <description>&lt;P&gt;Thanks Reeza, this worked!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 16:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420880#M27086</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-13T16:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420916#M27087</link>
      <description>&lt;P&gt;Note that Proc Format will allow you do some pretty creative custom formatting of dates and datetimes using directives.&lt;/P&gt;
&lt;P&gt;So you could create your own custom format, may be name it dtmmddyy to use showing only the date portion as desired without having to go the datepart route.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 17:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/420916#M27087</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-13T17:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/421393#M27130</link>
      <description>&lt;P&gt;Also good to know. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 21:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/421393#M27130</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-14T21:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Format Datetime to mm/dd/yyy</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/421712#M27158</link>
      <description>&lt;P&gt;Here are a couple of examples of custom datetime formats&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
/* default datetime18 shows 2 digit year (with 2 leading blanks, this makes custom
   datetime format that uses 18 digits and 4 digit year
   characters not part of a directive such as : or / are displayed as literal character
*/
picture mydatetime ( default=18)
low-high = '%d%b%Y:%H:%M:%S'   (datatype=datetime)
;
/*to display a datetime as first day of the month in mm/dd/yyyy appearance*/
picture dtfixed (default=10)
low-high = '%0m/01/%Y'  (datatype=datetime)
;
run;

data _null_;
   x='15Feb2017:10:12:13'dt;
   put x= mydatetime. x= datetime18. x= dtfixed.;
run;
&lt;/PRE&gt;
&lt;P&gt;Look in the Proc Format Picture statement for meanings of the directives. Do &lt;STRONG&gt;not&lt;/STRONG&gt; put the target value in side double quotes such as&lt;/P&gt;
&lt;P&gt;"%0m/01/%Y" as then the macro processor will kick in looking for macros named 0m and Y and many errors result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 20:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Format-Datetime-to-mm-dd-yyy/m-p/421712#M27158</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-15T20:50:36Z</dc:date>
    </item>
  </channel>
</rss>

