<?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: Date Format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715902#M27406</link>
    <description>&lt;P&gt;CP_Created is a datetime variable. Use DATEPART() function to extrat the date only from it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cp_created = datepart(cp_created);
format cp_created mmddyy10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the input is char type then yo need first to convert it to a numeric sas date variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = input(scan(cp_created,1,':'),date7.);
format date mmddyy10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Feb 2021 22:27:09 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2021-02-01T22:27:09Z</dc:date>
    <item>
      <title>Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715897#M27403</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having some trouble with date formatting. I am inputting a table that has a date variable that looks like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marleeakerson_0-1612217843539.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54223i5EBE7E3F85A9E21C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="marleeakerson_0-1612217843539.png" alt="marleeakerson_0-1612217843539.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But when I try to format it using this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format cp_createdat MMDDYY10. ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get this in the output table:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marleeakerson_1-1612217903974.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54224i0F27E31F5EECEBB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="marleeakerson_1-1612217903974.png" alt="marleeakerson_1-1612217903974.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Does anyone why this is/how to fix it? I am hoping to format this variable to be in the MM/DD/YYYY format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715897#M27403</guid>
      <dc:creator>marleeakerson</dc:creator>
      <dc:date>2021-02-01T22:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715900#M27404</link>
      <description>&lt;P&gt;You have a DATETIME variable, not a DATE variable. You need to use a DATETIME format, or convert it to a DATE variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATEPART will convert a datetime variable to a date variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can try adding DT in front of the desired format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format cp_createdat DTMMDDYY10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or a full conversion:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cp_create_date = datepart(cp_createdat);
format cp_create_date MMDDYY10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's a great, but longer and in depth, reference for dates and times in SAS&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715900#M27404</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-01T22:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715901#M27405</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format cp_createdat dtdate.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not the exact formatting you asked for, but it works. &lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715901#M27405</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-01T22:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715902#M27406</link>
      <description>&lt;P&gt;CP_Created is a datetime variable. Use DATEPART() function to extrat the date only from it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cp_created = datepart(cp_created);
format cp_created mmddyy10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the input is char type then yo need first to convert it to a numeric sas date variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = input(scan(cp_created,1,':'),date7.);
format date mmddyy10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715902#M27406</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-01T22:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715904#M27407</link>
      <description>&lt;P&gt;The reason you see ********** is that the underlying numeric value is larger than is expected by the MMDDYY format by about a factor of 86,400. Dates are measured by days in SAS and&amp;nbsp; datetime values like you have are measured in seconds. So one "day" of a date time is 86,400 seconds and way to large for consideration as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to talk to whoever is creating that file and beat them severely with wet spaghetti noodles for using a 2-digit year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the values you show represent what I call the "lazy Microsoft office programmer" of allowing a "date" to default to a datetime field with 0 hours, 0 minutes and 0 seconds. Useless and ugly if there is not actual time component used.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Format/m-p/715904#M27407</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-01T22:45:29Z</dc:date>
    </item>
  </channel>
</rss>

