<?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: SAS date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930917#M366253</link>
    <description>&lt;P&gt;What did you try?&amp;nbsp; What datetime value do you think that string represents?&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2024 13:36:36 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-06-05T13:36:36Z</dc:date>
    <item>
      <title>SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930915#M366252</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the below dataset&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input original_date $50.;
    datalines;
Mon Mar 11 12:01:41 UTC 2024
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Need a new column (string) with the original date in the format&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;yyyy-mm-ddThh:mm:ssZ.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;How can this be done. Thank you&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 12:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930915#M366252</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-06-05T12:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930917#M366253</link>
      <description>&lt;P&gt;What did you try?&amp;nbsp; What datetime value do you think that string represents?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 13:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930917#M366253</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-05T13:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930918#M366254</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input _Dow:$3. _M:$3. _D _T:$8. _Z:$3. _Y;
	 Original_date=_infile_;
	 Datetime_string=cats(put(_D,2.),_M,put(_Y,4.),'T',_t,_Z);
	 drop _:;
    datalines;
Mon Mar 11 12:01:41 UTC 2024
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jun 2024 13:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930918#M366254</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-06-05T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930924#M366259</link>
      <description>&lt;P&gt;You will probably need to use SCAN() to break that string into its pieces so you can combine them together in the right way to make datetime value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input original_date $50.;
datalines;
Mon Mar 11 12:01:41 UTC 2024
;

data want;
  set have;
  dayname=scan(original_date,1,' ');
  monname=scan(original_date,2,' ');
  day=input(scan(original_date,3,' '),?32.);
  tod=input(scan(original_date,4,' '),time24.);
  tz=scan(original_date,5,' ');
  system_tz = getoption('timezone');
  year=input(scan(original_date,6,' '),?32.);
  date=input(cats(day,monname,year),date9.);
  datetime=dhms(date,0,0,tod);
  offset = tzoneoff(tz,datetime);
  format tod tod8. date date9. datetime E8601dt.;
  put (_all_) (=/);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;original_date=Mon Mar 11 12:01:41 UTC 2024
dayname=Mon
monname=Mar
day=11
tod=12:01:41
tz=UTC
system_tz=
year=2024
date=11MAR2024
datetime=2024-03-11T12:01:41
offset=0
&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jun 2024 14:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-format/m-p/930924#M366259</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-05T14:00:14Z</dc:date>
    </item>
  </channel>
</rss>

