<?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 Formatting Issue in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927102#M41605</link>
    <description>&lt;P&gt;Hi, I have a SAS dataset wherein date format is incorrect and the same is to be corrected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help in the matter.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data A;&lt;BR /&gt;input Employee_Id $ Date Date9. ;&lt;BR /&gt;cards;&lt;/P&gt;
&lt;P&gt;70202028 - 04JAN2023;&lt;/P&gt;
&lt;P&gt;70204018 - 04SEP2023;&lt;/P&gt;
&lt;P&gt;70172038&amp;nbsp; - 27MAR2023;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set a;&lt;/P&gt;
&lt;P&gt;70202028 - 01APR2023; /*to be changed*/&lt;/P&gt;
&lt;P&gt;70204018 - 09APR2023;&amp;nbsp;/*to be changed*/&lt;/P&gt;
&lt;P&gt;70172038&amp;nbsp; - 27MAR2023;&amp;nbsp;/*this is correct and it should not be changed*/&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 May 2024 18:11:17 GMT</pubDate>
    <dc:creator>sanjaymane7</dc:creator>
    <dc:date>2024-05-05T18:11:17Z</dc:date>
    <item>
      <title>Date Formatting Issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927102#M41605</link>
      <description>&lt;P&gt;Hi, I have a SAS dataset wherein date format is incorrect and the same is to be corrected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help in the matter.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data A;&lt;BR /&gt;input Employee_Id $ Date Date9. ;&lt;BR /&gt;cards;&lt;/P&gt;
&lt;P&gt;70202028 - 04JAN2023;&lt;/P&gt;
&lt;P&gt;70204018 - 04SEP2023;&lt;/P&gt;
&lt;P&gt;70172038&amp;nbsp; - 27MAR2023;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set a;&lt;/P&gt;
&lt;P&gt;70202028 - 01APR2023; /*to be changed*/&lt;/P&gt;
&lt;P&gt;70204018 - 09APR2023;&amp;nbsp;/*to be changed*/&lt;/P&gt;
&lt;P&gt;70172038&amp;nbsp; - 27MAR2023;&amp;nbsp;/*this is correct and it should not be changed*/&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 May 2024 18:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927102#M41605</guid>
      <dc:creator>sanjaymane7</dc:creator>
      <dc:date>2024-05-05T18:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Date Formatting Issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927103#M41606</link>
      <description>&lt;P&gt;Base on what rules those dates should be changed ?&lt;/P&gt;</description>
      <pubDate>Sun, 05 May 2024 18:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927103#M41606</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-05-05T18:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date Formatting Issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927105#M41607</link>
      <description>&lt;P&gt;Where did this data come from? How did you get it into SAS.&lt;/P&gt;
&lt;P&gt;It looks like you mistakenly read in values in MDY order as if they were in DMY order (or the reverse).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should probably fix the step that makes the data originally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really do want to switch the month and day when the day is less than 13 then you could do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have;
  if day(date) in (1:12) then date=mdy(day(date),month(date),year(date));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Your posted data step cannot work.&amp;nbsp; Do not add the hyphens and semicolons into the in-line data lines.&amp;nbsp; Do not use FORMATTED MODE to read the DATE value, use LIST MODE instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input Employee_Id $ Date :date. ;
  format date date9.;
cards;
70202028 04JAN2023
70204018 04SEP2023
70172038 27MAR2023
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 May 2024 19:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927105#M41607</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-05T19:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date Formatting Issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927116#M41608</link>
      <description>&lt;P&gt;Hi, I got this readymade file from someone. I was trying to correct it. Thank you so much. Today is my review meeting and you saved my job. Thank you again&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 01:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927116#M41608</guid>
      <dc:creator>sanjaymane7</dc:creator>
      <dc:date>2024-05-06T01:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date Formatting Issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927126#M41609</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296098"&gt;@sanjaymane7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I got this readymade file from someone. I was trying to correct it. Thank you so much. Today is my review meeting and you saved my job. Thank you again&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you have learned something.&lt;/P&gt;
&lt;P&gt;1) Never use either MDY or DMY ordering when writing dates into text files (like CSV files).&amp;nbsp; Only use unambiguous styles like the DATE or YYMMDD formats produce.&lt;/P&gt;
&lt;P&gt;2) Never use ANYDT... informats to read in date strings without first making sure that the DATESTYLE system option is set to the proper value for your data file.&amp;nbsp; Either MDY or DMY.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 04:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-Formatting-Issue/m-p/927126#M41609</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-06T04:40:43Z</dc:date>
    </item>
  </channel>
</rss>

