<?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 Date format problem in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534253#M6276</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my file I have date written in this form (20131126). I want to keep only year and month(201311)&lt;/P&gt;&lt;P&gt;I tried the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Format date yymmn;&amp;nbsp; (not my variable name is date)&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is not working. I am not getting the desired result. Please help.&lt;/P&gt;</description>
    <pubDate>Sun, 10 Feb 2019 05:36:51 GMT</pubDate>
    <dc:creator>abdulla</dc:creator>
    <dc:date>2019-02-10T05:36:51Z</dc:date>
    <item>
      <title>Date format problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534253#M6276</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my file I have date written in this form (20131126). I want to keep only year and month(201311)&lt;/P&gt;&lt;P&gt;I tried the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Format date yymmn;&amp;nbsp; (not my variable name is date)&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is not working. I am not getting the desired result. Please help.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 05:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534253#M6276</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2019-02-10T05:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Date format problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534255#M6277</link>
      <description>&lt;P&gt;Try&amp;nbsp; this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format date yymmn6.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Feb 2019 06:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534255#M6277</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-02-10T06:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Date format problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534256#M6278</link>
      <description>No, it doesn't work. I got 2.01E7. Also I am continuously getting the following msg.&lt;BR /&gt;ERROR: There was a problem with the format so BEST. was used.&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Feb 2019 06:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534256#M6278</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2019-02-10T06:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Date format problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534257#M6279</link>
      <description>&lt;P&gt;OK, that means your date isn't an actual SAS date, which holds a number for the days since 1 Jan 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run this test with an actual SAS date and check the log to prove it for yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   mydate='14may2018'd;
   format mydate yymmn6.;
   put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please post an example of your date data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 07:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534257#M6279</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-02-10T07:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Date format problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534289#M6286</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/260675"&gt;@abdulla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No, it doesn't work. I got 2.01E7. Also I am continuously getting the following msg.&lt;BR /&gt;ERROR: There was a problem with the format so BEST. was used.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If your value is printing as 2.01E7 then it is neither a date (number of days since 1960) or a datetime (number of seconds since 1960).&lt;/P&gt;
&lt;PRE&gt;269   data test;
270     x= 2.01E7 ;
271     put 'COMMA15. ' @13 x comma15. ;
272     put 'DATE9. '   @13 x date9. ;
273     put 'DATETIME20. ' @13 x datetime20. ;
274   run;

COMMA15.         20,100,000
DATE9.      *********
DATETIME20.   20AUG1960:15:20:00
&lt;/PRE&gt;
&lt;P&gt;Looks like you might have stored you dates as numbers where the tens and ones place represent the day of the month, etc.&lt;/P&gt;
&lt;P&gt;To convert them into actual dates use could use an INPUT() function.&amp;nbsp; You will first need to convert them into a string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have;
  date = input(put(date,8.),yymmdd8.);
  format date yymmdd10. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 14:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-problem/m-p/534289#M6286</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-10T14:13:13Z</dc:date>
    </item>
  </channel>
</rss>

