<?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 issue with dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441020#M282570</link>
    <description>&lt;P&gt;Use SCAN() to separate the date and time portions&lt;/P&gt;
&lt;P&gt;Use INPUT() to convert to SAS date/time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;untested&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(date) then do; *check for missing first so you don't get a bunch of errors in your log;

date_part1 = scan(date_var, 1, '@');
time_part1 = scan(date_var, 2, '@');

date_sas = input(date_part1, anydtdte.);
format date_sas date9.;

time_sas = input(time_part1, time.);
format time_sas time.;

end;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Feb 2018 21:05:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-28T21:05:31Z</dc:date>
    <item>
      <title>SAS issue with dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441016#M282569</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am very new to SAS and I have a question, and I apologize if I am not clear or descriptive enough.&amp;nbsp; I imported data from excel into SAS and I need to change the dates.&amp;nbsp;&amp;nbsp;Not every cell&amp;nbsp;has a date.&amp;nbsp; The blank cells are filled with a&amp;nbsp;double hyphen --. &amp;nbsp; &amp;nbsp;The column attributes are character and the format and informat is $18.&amp;nbsp; My question is how do I change the below date to month and year.&amp;nbsp; Below is an example of how it looks like.&amp;nbsp; Thank you for all of your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;AUG 05, 2015@15:30&lt;/P&gt;&lt;P&gt;AUG 05, 2015@15:30&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;AUG 03, 2015@17:20&lt;/P&gt;&lt;P&gt;AUG 03, 2015@17:20&lt;/P&gt;&lt;P&gt;AUG 03, 2015@17:20&lt;/P&gt;&lt;P&gt;AUG 03, 2015@17:20&lt;/P&gt;&lt;P&gt;AUG 03, 2015@17:20&lt;/P&gt;&lt;P&gt;AUG 03, 2015@17:20&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 20:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441016#M282569</guid>
      <dc:creator>StefB</dc:creator>
      <dc:date>2018-02-28T20:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS issue with dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441020#M282570</link>
      <description>&lt;P&gt;Use SCAN() to separate the date and time portions&lt;/P&gt;
&lt;P&gt;Use INPUT() to convert to SAS date/time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;untested&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(date) then do; *check for missing first so you don't get a bunch of errors in your log;

date_part1 = scan(date_var, 1, '@');
time_part1 = scan(date_var, 2, '@');

date_sas = input(date_part1, anydtdte.);
format date_sas date9.;

time_sas = input(time_part1, time.);
format time_sas time.;

end;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 21:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441020#M282570</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-28T21:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS issue with dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441032#M282571</link>
      <description>This may be as stupid question, but how do I check for missing?</description>
      <pubDate>Wed, 28 Feb 2018 21:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441032#M282571</guid>
      <dc:creator>StefB</dc:creator>
      <dc:date>2018-02-28T21:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS issue with dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441045#M282573</link>
      <description>&lt;P&gt;Tested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length date_Var $32;
input date_Var &amp;amp;;
datalines;
--
AUG 05, 2015@15:30
AUG 03, 2015@17:20
--
;

data want;
set have;
if length(date_Var) &amp;gt; 9 then do;
    date_part1 = prxchange("s/(\w+)\s*(\d+)[, ]+(\d+)@.*/$2$1$3/o", 1, date_Var);
    time_part1 = scan(date_var, 2, '@');
    date_sas = input(date_part1, date.);
    time_sas = input(time_part1, time.);
    end;
format date_sas date9. time_sas time.;
run;

proc print; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;      Obs    date_Var                part1      part1     date_sas    time_sas

       1     --                                                  .           .
       2     AUG 05, 2015@15:30    05AUG2015    15:30    05AUG2020    15:30:00
       3     AUG 03, 2015@17:20    03AUG2015    17:20    03AUG2020    17:20:00
       4     --                                                  .           .
&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 21:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-issue-with-dates/m-p/441045#M282573</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-28T21:58:13Z</dc:date>
    </item>
  </channel>
</rss>

