<?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 How to read the Date in yymm format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360090#M84710</link>
    <description>&lt;P&gt;Hello Expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have date data like yymm format storing character datatype.&lt;/P&gt;&lt;P&gt;first two letter represent year(yy) and 3rd-4th digit represent month(mm).&lt;/P&gt;&lt;P&gt;I want to add date (01) in evey row &amp;nbsp;and want to show my date in dd mm yy format in char data type.&lt;/P&gt;&lt;P&gt;How can we do it, Please help me.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Source data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Trans_dt&lt;/P&gt;&lt;P&gt;-------------&lt;/P&gt;&lt;P&gt;1705&lt;/P&gt;&lt;P&gt;1811&lt;/P&gt;&lt;P&gt;2101&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Trans_dt&lt;/P&gt;&lt;P&gt;----------------&lt;/P&gt;&lt;P&gt;01-05-2017&lt;/P&gt;&lt;P&gt;01-11-2018&lt;/P&gt;&lt;P&gt;01-01-2021&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2017 19:30:07 GMT</pubDate>
    <dc:creator>Riteshdell</dc:creator>
    <dc:date>2017-05-19T19:30:07Z</dc:date>
    <item>
      <title>How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360090#M84710</link>
      <description>&lt;P&gt;Hello Expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have date data like yymm format storing character datatype.&lt;/P&gt;&lt;P&gt;first two letter represent year(yy) and 3rd-4th digit represent month(mm).&lt;/P&gt;&lt;P&gt;I want to add date (01) in evey row &amp;nbsp;and want to show my date in dd mm yy format in char data type.&lt;/P&gt;&lt;P&gt;How can we do it, Please help me.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Source data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Trans_dt&lt;/P&gt;&lt;P&gt;-------------&lt;/P&gt;&lt;P&gt;1705&lt;/P&gt;&lt;P&gt;1811&lt;/P&gt;&lt;P&gt;2101&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Trans_dt&lt;/P&gt;&lt;P&gt;----------------&lt;/P&gt;&lt;P&gt;01-05-2017&lt;/P&gt;&lt;P&gt;01-11-2018&lt;/P&gt;&lt;P&gt;01-01-2021&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 19:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360090#M84710</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-05-19T19:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360093#M84712</link>
      <description>&lt;P&gt;Read the date as $4 then create the sas numeric date:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; input datex $4.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; date = input(datex||'01' , yymmdd8.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; format date ddmmyy10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; drop datex;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;1705&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 19:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360093#M84712</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-19T19:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360094#M84713</link>
      <description>&lt;P&gt;I, personally, think it would be more advantageous to store the date as a SAS date and include a format in order to have it appear in the format you want. Regardless, here is how to do it both ways:&lt;/P&gt;
&lt;PRE&gt;data have;
  input cdate $;
  date=mdy(substr(cdate,3),1,substr(cdate,1,2));
  format date ddmmyyd10.;
  date_as_char=put(date,ddmmyyd10.);
  cards;
1705
1811
2101
;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 19:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360094#M84713</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-19T19:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360095#M84714</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data in;
    input value $;
    yy=substr(value,1,2)+0;
    mm=susbtr(value,3,2)+0;
    date=mdy(mm,1,yy);
    format date ddmmyyd10.;
cards;
1705
1811
2101
;
run;
proc print data=in;
    var date;
Run;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 May 2017 19:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360095#M84714</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-05-19T19:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360097#M84715</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; trans_dt $;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1705&lt;/P&gt;&lt;P&gt;1811&lt;/P&gt;&lt;P&gt;2101&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;rename&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=(new_date=trans_dt));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;new_date=cats(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'01'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"-"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,substr(trans_dt,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;),&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"-"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;+substr(trans_dt,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; trans_dt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 19:54:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360097#M84715</guid>
      <dc:creator>PBsas</dc:creator>
      <dc:date>2017-05-19T19:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360099#M84716</link>
      <description>&lt;P&gt;Is it already in a SAS dataset or are you reading from a text file? Is it a character or numeric variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use MDY() function along with SUBSTRN. This is assuming a numeric variable already in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;my_date = MDY(substrn(old_date, 3, 2), 1, substrn(old_date, 1, 2));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 19:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360099#M84716</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-19T19:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Date in yymm format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360108#M84721</link>
      <description>&lt;P&gt;Another&lt;/P&gt;
&lt;PRE&gt;options yearcutoff=1930;
data example;
   informat trans_dt yymmn4.;
   input trans_dt;
   format trans_dt mmddyyd10.;
datalines;
1705
1811
2101
;
run;&lt;/PRE&gt;
&lt;P&gt;Note teh YYMMN format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also how do you know that 2101 is in year 2021? Especially since it is in the future. The yearcutoff option sets a limit for 2 digit years and how SAS treats them by default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very strongly suggest use of a DATE value with the correct format as it is much more flexible.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 20:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-Date-in-yymm-format/m-p/360108#M84721</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-19T20:24:14Z</dc:date>
    </item>
  </channel>
</rss>

