<?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: How to define date from a given date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459956#M116867</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the anydtdte21. informat to read this type of data, it r&lt;SPAN&gt;eads and extracts the date value from various date, time, and datetime forms.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pls refer to code below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data need;
input date_var anydtdte21.;
datalines;
2018/04/22
20180422
2018-04-22
2018-04-22 05:36:02
13042018
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;More details here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605538.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605538.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give a like and mark as solution if it helped.&lt;/P&gt;</description>
    <pubDate>Fri, 04 May 2018 08:21:06 GMT</pubDate>
    <dc:creator>mnjtrana</dc:creator>
    <dc:date>2018-05-04T08:21:06Z</dc:date>
    <item>
      <title>How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459932#M116862</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Need help&lt;/P&gt;&lt;P&gt;I have been provided with various dates in .txt file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;2018/04/22&lt;/P&gt;&lt;P&gt;20140422&lt;/P&gt;&lt;P&gt;2018-04-22&lt;/P&gt;&lt;P&gt;2018-04-22 05:34:46&lt;/P&gt;&lt;P&gt;04222018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to define date format pattern, and need output as&lt;/P&gt;&lt;P&gt;yyyy/mm/dd&lt;/P&gt;&lt;P&gt;yyyymmdd&lt;/P&gt;&lt;P&gt;yyyy-mm-dd&lt;/P&gt;&lt;P&gt;yyyy-mm-dd hh:mm:ss&lt;/P&gt;&lt;P&gt;mmddyyyy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and also Like to know, if date id above for example&amp;nbsp;&lt;/P&gt;&lt;P&gt;13022018&lt;/P&gt;&lt;P&gt;if it is above 12 as you see above starting 2 digit is 13 so it is dd only not month because month will be 01-12 right,&lt;/P&gt;&lt;P&gt;so I dont no, how to handle this type of dates.&lt;/P&gt;&lt;P&gt;Could you please help me with this&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 04:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459932#M116862</guid>
      <dc:creator>harry_87</dc:creator>
      <dc:date>2018-05-04T04:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459954#M116866</link>
      <description>&lt;P&gt;What you will need to do is some string manipulation.&amp;nbsp; You can look into pearl regular expressions:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf" target="_blank"&gt;https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And build up patterns from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you go through and build up your conditions using if logic, e.g.:&lt;/P&gt;
&lt;P&gt;If string contains / then delimter=/&lt;/P&gt;
&lt;P&gt;If string contains - then delimter=-&lt;/P&gt;
&lt;P&gt;If length &amp;gt; 10 then date/time&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not writing it all out for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for: "and also Like to know, if date id above for example&amp;nbsp;&lt;/P&gt;
&lt;P&gt;13022018&lt;/P&gt;
&lt;P&gt;if it is above 12 as you see above starting 2 digit is 13 so it is dd only not month because month will be 01-12 right,&lt;/P&gt;
&lt;P&gt;so I dont no, how to handle this type of dates." - I have no idea what you mean.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 08:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459954#M116866</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T08:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459956#M116867</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the anydtdte21. informat to read this type of data, it r&lt;SPAN&gt;eads and extracts the date value from various date, time, and datetime forms.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pls refer to code below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data need;
input date_var anydtdte21.;
datalines;
2018/04/22
20180422
2018-04-22
2018-04-22 05:36:02
13042018
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;More details here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605538.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605538.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give a like and mark as solution if it helped.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 08:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459956#M116867</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2018-05-04T08:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459957#M116868</link>
      <description>&lt;P&gt;You could use the ANYDTDTE. informat:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; informat date anydtdte.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; format date date9.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; input date;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;cards;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;2018/04/22&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;20140422&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;2018-04-22&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;2018-04-22 05:34:46&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;04222018&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In some cases, it is not clear how a date whould be read. Does 010403 mean 01APR2003, 04JAN2003 or 03APR2001? You can set your preferred input style with the DATESTYLE option.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 08:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459957#M116868</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-05-04T08:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459960#M116869</link>
      <description>&lt;P&gt;Perhaps be clearer about what you want.&amp;nbsp; Do you want, as I understood from your post, to get the structure of the date as a text pattern, or do you just want to read in some text into a date format variable as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp;has presented?&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 08:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459960#M116869</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T08:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459974#M116875</link>
      <description>&lt;P&gt;I want structure as date as date pattern&amp;nbsp;&lt;/P&gt;&lt;P&gt;But Yes, if 01122018 so how to handle this 01Dec2018 or 21JAN2018 that I dont no,&amp;nbsp;&lt;/P&gt;&lt;P&gt;options datestyle will work not sure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 09:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459974#M116875</guid>
      <dc:creator>harry_87</dc:creator>
      <dc:date>2018-05-04T09:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459977#M116878</link>
      <description>&lt;P&gt;In which case then use perl regular expressions or if statements as I said to process the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AS for your second question, we cannot answer this.&amp;nbsp; Only the person who created that date can tell you what the intent was.&amp;nbsp; There is no logical way of identifying which of the possible dates that is supposed to represent.&amp;nbsp; To be honest if it was me, I would be sending that data back to source and asking them to do their job properly by creating useful accurate data, and provide a data description to boot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 09:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459977#M116878</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T09:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459996#M116886</link>
      <description>&lt;P&gt;Second what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;said. Return to sender and ask what they've been smoking.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/459996#M116886</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-04T10:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to define date from a given date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/460290#M116979</link>
      <description>&lt;P&gt;OK , thanks for reply&lt;/P&gt;</description>
      <pubDate>Sun, 06 May 2018 12:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-date-from-a-given-date/m-p/460290#M116979</guid>
      <dc:creator>harry_87</dc:creator>
      <dc:date>2018-05-06T12:54:52Z</dc:date>
    </item>
  </channel>
</rss>

