<?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: facing date issue in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805432#M33487</link>
    <description>&lt;P&gt;Thanks a ton&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 05:34:06 GMT</pubDate>
    <dc:creator>aanan1417</dc:creator>
    <dc:date>2022-04-01T05:34:06Z</dc:date>
    <item>
      <title>facing date issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805197#M33461</link>
      <description>&lt;P&gt;i have excel file that contain variable like name age date.&lt;/P&gt;
&lt;P&gt;and every date is in different format.&lt;/P&gt;
&lt;P&gt;i import this date as character and now the problem is i dont no how to get date in one format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input name age date;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;rahul 66 03dec2020&lt;/P&gt;
&lt;P&gt;rohit&amp;nbsp; 55 2020nov17&lt;/P&gt;
&lt;P&gt;nisha 44 12/10/2020&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;input name age date;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;rahul 66 03dec2020&lt;/P&gt;
&lt;P&gt;rohit&amp;nbsp; 55 17nov2020&lt;/P&gt;
&lt;P&gt;nisha 44 10dec2020&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 05:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805197#M33461</guid>
      <dc:creator>aanan1417</dc:creator>
      <dc:date>2022-03-31T05:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: facing date issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805200#M33462</link>
      <description>&lt;P&gt;Please fix the obvious errors in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT 1:&lt;/P&gt;
&lt;P&gt;Some questions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Is it sure, that in dates like "12/10/2020" the second part (10) is always the day an never the month of the date?&lt;/LI&gt;
&lt;LI&gt;All "dates" always have day, month and year?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT 2:&lt;/P&gt;
&lt;P&gt;Working with the data you have posted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have(rename=(date = str_date));

   attrib date length=8 format=date9.;

   date = input(str_date, ?? anydtdte.);

   if missing(date) then do;
      date = input(str_date, ?? mmddyy10.);
   end;

   if missing(date) then do;
      put "ERROR: Can't convert date in obs " _n_;
      put _all_;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Mar 2022 06:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805200#M33462</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-03-31T06:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: facing date issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805321#M33474</link>
      <description>&lt;P&gt;First comment: make sure that shown data step code runs. Yours has errors (fixed).&lt;/P&gt;
&lt;PRE&gt;data have;
input name :$10. age date :$15.;
datalines;
rahul 66 03dec2020
rohit  55 2020nov17
nisha 44 12/10/2020
;

data want (rename=(newdate=date));
  set have;
  newdate = input(date,anydtdte32.);
  format newdate date9.;
  drop date;
run;
 &lt;/PRE&gt;
&lt;P&gt;The Anydtdte (any date ) informat will read many but not all common date formats. Problems typically come when using two-digit years as then a value like 01/02/03 can't tell which is actually the year (or day of the month or month in this case).&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805321#M33474</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-31T14:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: facing date issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805324#M33475</link>
      <description>&lt;P&gt;And the "ANY" informats will come to different results depending on locale. A date shown as xx/xx/xxxx can be MDY &amp;nbsp;(e.g. USA) or DMY (Europe, Australia).&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805324#M33475</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-31T14:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: facing date issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805432#M33487</link>
      <description>&lt;P&gt;Thanks a ton&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 05:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/facing-date-issue/m-p/805432#M33487</guid>
      <dc:creator>aanan1417</dc:creator>
      <dc:date>2022-04-01T05:34:06Z</dc:date>
    </item>
  </channel>
</rss>

