<?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 formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320414#M70568</link>
    <description>&lt;P&gt;what should be the output for&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2016&lt;/P&gt;
&lt;P&gt;un-18-2018&lt;/P&gt;
&lt;P&gt;un-unk-2016&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2016 07:29:13 GMT</pubDate>
    <dc:creator>chrej5am</dc:creator>
    <dc:date>2016-12-21T07:29:13Z</dc:date>
    <item>
      <title>date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320410#M70565</link>
      <description>&lt;P&gt;Hi I have following data ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dates&lt;/P&gt;&lt;P&gt;13APR1999&lt;/P&gt;&lt;P&gt;120499&lt;/P&gt;&lt;P&gt;2016-11-19&lt;/P&gt;&lt;P&gt;11-18-2016&lt;/P&gt;&lt;P&gt;2016&lt;/P&gt;&lt;P&gt;un-18-2018&lt;/P&gt;&lt;P&gt;un-unk-2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to get all these dated to yymmdd10. format,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 07:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320410#M70565</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T07:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320414#M70568</link>
      <description>&lt;P&gt;what should be the output for&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2016&lt;/P&gt;
&lt;P&gt;un-18-2018&lt;/P&gt;
&lt;P&gt;un-unk-2016&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 07:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320414#M70568</guid>
      <dc:creator>chrej5am</dc:creator>
      <dc:date>2016-12-21T07:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320415#M70569</link>
      <description>&lt;P&gt;for 2106 the output should be 2016&lt;/P&gt;&lt;P&gt;for&amp;nbsp;&lt;/P&gt;&lt;P&gt;un-18-2018 &amp;nbsp; &amp;nbsp; &amp;nbsp;2016-18- &amp;nbsp;&lt;/P&gt;&lt;P&gt;un-unk-2016 &amp;nbsp; &amp;nbsp; 2016- &amp;nbsp;- &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there should be blank in the place of un and unk&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 07:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320415#M70569</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T07:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320420#M70573</link>
      <description>&lt;P&gt;If do not intend to convert the input into sas date variable then just read it a&amp;nbsp;&lt;/P&gt;
&lt;P&gt;alphanumeric and replace the un/unk inro space:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;infile datalines truncover;&lt;/P&gt;
&lt;P&gt;input datex $10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; datex = tranword(datex, ' &amp;nbsp;','un');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; datex = translate(datex,' ','k');&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;13APR1999&lt;/P&gt;
&lt;P&gt;120499&lt;/P&gt;
&lt;P&gt;2016-11-19&lt;/P&gt;
&lt;P&gt;11-18-2016&lt;/P&gt;
&lt;P&gt;2016&lt;/P&gt;
&lt;P&gt;un-18-2018&lt;/P&gt;
&lt;P&gt;un-unk-2016&lt;/P&gt;
&lt;P&gt;; run;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 07:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320420#M70573</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-21T07:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320422#M70575</link>
      <description>&lt;P&gt;I need to convert that to sas date varaible and display in yymmdd10.format&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 07:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320422#M70575</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T07:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320423#M70576</link>
      <description>&lt;P&gt;You can not have this kind of output in the column with ordinary&amp;nbsp;&lt;SPAN&gt;yymmdd10. format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Either construct your own format&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;extract Year Month and Date from your input and based on availability of these values construct date column formatted as&amp;nbsp;yymmdd10.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 07:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320423#M70576</guid>
      <dc:creator>chrej5am</dc:creator>
      <dc:date>2016-12-21T07:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320426#M70577</link>
      <description>&lt;P&gt;how would you interpre input like: &lt;STRONG&gt;09-05-2015&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;is it a ddmmyy10. informat or mmddyy10. informat ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and what about: 120499 - is ir 12apr1999 or 12apr2099 or 04dec1999 etc?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot have a unque result unless you have some more restrictions.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320426#M70577</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-21T08:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320427#M70578</link>
      <description>&lt;P&gt;ok..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the case of 13APR1999 input, can I compare the variable with sas datesets and convert them to yymmdd10. format, like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if datetest=date9. then&amp;nbsp;&lt;/P&gt;&lt;P&gt;d1=input(datetest,yymmdd10.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In these way can i compare the varable with every sas date format and convert them to yyddmm10. format&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320427#M70578</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T08:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320429#M70579</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116130"&gt;@molla&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;for 2106 the output should be 2016&lt;/P&gt;
&lt;P&gt;for&amp;nbsp;&lt;/P&gt;
&lt;P&gt;un-18-2018 &amp;nbsp; &amp;nbsp; &amp;nbsp;2016-18- &amp;nbsp;&lt;/P&gt;
&lt;P&gt;un-unk-2016 &amp;nbsp; &amp;nbsp; 2016- &amp;nbsp;- &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there should be blank in the place of un and unk&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can`t do that with the standard YYMMDD10. format; it needs a date value as input, and will always display days and months.&lt;/P&gt;
&lt;P&gt;You will have to keep year, month and day in different variables so you can store the un/unk as missing values there, while preserving the non-missing year (or month).&lt;/P&gt;
&lt;P&gt;BTW, there is no 18th month in the Gregorian calendar &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320429#M70579</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-21T08:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320430#M70580</link>
      <description>&lt;P&gt;for all the possible sas date informats i need to convert to yymmdd10. format,there I have given only few date informats,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320430#M70580</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T08:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320431#M70581</link>
      <description>&lt;P&gt;My requirement is consider a varaible which contain all the possible date informats of sas ,some of the months ,years are missing in the observations ,I need to convert all those to a common standard frmat yymdd10.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320431#M70581</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T08:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320432#M70582</link>
      <description>&lt;P&gt;here 18 is not month it is date, it id in mmddyy10. format&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320432#M70582</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2016-12-21T08:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320433#M70583</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116130"&gt;@molla&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;My requirement is consider a varaible which contain all the possible date informats of sas ,some of the months ,years are missing in the observations ,I need to convert all those to a common standard frmat yymdd10.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is only possible if you keep year, month and day in separate variables. A SAS date value (just like a date value in any programming environment) is a count of days from a certain offset (1960-01-01 in the case of SAS) and will always contain a valid month and day.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320433#M70583</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-21T08:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320434#M70584</link>
      <description>&lt;P&gt;Do you know the informat ahead of time?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you deriving it based on the appearance of the data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned,&amp;nbsp;mmddyy and ddmmyy are both valid informats that cannot be uniquely identified.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't know the format this may not be possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS catch all informat is ANYDTDTE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your exact data, please post the expected results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320434#M70584</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-21T08:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320438#M70586</link>
      <description>&lt;P&gt;Here is a code to convert your sample into sas dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;infile datalines truncover;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;input datex $12.; /* anydate10.; */&lt;BR /&gt;&amp;nbsp; &amp;nbsp;datex = lowcase(datex);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* &lt;STRONG&gt;define your preferenced order of trial&lt;/STRONG&gt; */&lt;BR /&gt;&amp;nbsp; if input(datex,?? date9.) &amp;gt; 0 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;then date = input(datex,date9.); else&lt;BR /&gt;&amp;nbsp; if input(datex,?? date7.) &amp;gt; 0 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;then date = input(datex,date9.); else&lt;BR /&gt;&amp;nbsp;if input(datex,?? ddmmyy10.) &amp;gt; 0 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; then date = input(datex,ddmmyy10.); else&lt;BR /&gt;&amp;nbsp;if input(datex,?? yymmdd10.) &amp;gt; 0 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; then date = input(datex,yymmdd10.); &lt;BR /&gt;else do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;datex = translate(datex,' ','unk');&lt;BR /&gt;&amp;nbsp; &amp;nbsp;do i=1 to 3;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;num = scan(datex,i,'-/');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (0 &amp;lt; num le 12) then mm=num; else&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (0 &amp;lt; num le 31) then dd=num; else&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if num le 99 or num &amp;gt; 1900 then yy=num; /* year 2 or 4 digits */&lt;BR /&gt;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if yy =. then yy = input(datex, ?? best11.);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if dd le 0 then dd=01;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if mm le 0 then mm=01;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;date = mdy(mm,dd,yy);&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;format date ddmmyy10.;&lt;/P&gt;
&lt;P&gt;datalines;&lt;BR /&gt;13apr1999&lt;BR /&gt;120499&lt;BR /&gt;2016-11-19&lt;BR /&gt;11-18-2016&lt;BR /&gt;2016&lt;BR /&gt;un-18-2018&lt;BR /&gt;un-unk-2016&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT, as I posted earlier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;how would you interpret input like: 09-05-2015
is it a ddmmyy10. informat or mmddyy10. informat ?
 
and what about: 120499 - is it 12apr1999 or 12apr2099 or 04dec1999 etc?
 
You cannot have a unique result unless you have some more restrictions.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Dec 2016 08:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320438#M70586</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-21T08:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320445#M70590</link>
      <description>&lt;P&gt;See the notes and solution in this paper&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/117-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/117-2011.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 09:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/320445#M70590</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-21T09:26:30Z</dc:date>
    </item>
  </channel>
</rss>

