<?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: PRXCHANGE or RXCHANGE for String Dates in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71812#M20751</link>
    <description>If you want to learn regular expressions, by all means, let the forum know that you are still waiting for a response.  However, you indicated that you wanted to correct the situation that you had.  You can do that with only using put and input.  For example:&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  want_date=put(input(have_date,mmddyy10.),mmddyy10.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art</description>
    <pubDate>Mon, 13 Sep 2010 20:17:30 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2010-09-13T20:17:30Z</dc:date>
    <item>
      <title>PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71811#M20750</link>
      <description>Experts:&lt;BR /&gt;
&lt;BR /&gt;
I am facing a situation&lt;BR /&gt;
&lt;BR /&gt;
I have date in a format M/D/YYYY  &lt;B&gt;and this is a string&lt;/B&gt;.&lt;BR /&gt;
m stands for single digit month (i.e. 1 instead of 01 for Jan). &lt;BR /&gt;
d stands for single digit data (e.g. 1 instead of 01 for first day of themonth, YYYY - 4 digit year).&lt;BR /&gt;
&lt;BR /&gt;
Is there a way I can use rxchange or prxchange and look for single digit month &amp;amp; day and convert them to double digit. eg&lt;BR /&gt;
&lt;BR /&gt;
7/07/2010 to 07/07/2010 or&lt;BR /&gt;
7/7/2010 to 07/07/2010 or&lt;BR /&gt;
10/1/2010 to 10/01/2010&lt;BR /&gt;
&lt;BR /&gt;
Here's what I tried:&lt;BR /&gt;
DATA try;&lt;BR /&gt;
INPUT dt $CHAR40.;&lt;BR /&gt;
txt= prxparse( 's/(\d\/)/0\d\//');&lt;BR /&gt;
text = prxchange(txt, -1, dt);&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
7/07/2009&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
result :&lt;BR /&gt;
    dt        txt        text&lt;BR /&gt;
&lt;BR /&gt;
  7/07/2009     1     0\d/00\d/2009

Message was edited by: Pdogra</description>
      <pubDate>Mon, 13 Sep 2010 18:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71811#M20750</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-13T18:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71812#M20751</link>
      <description>If you want to learn regular expressions, by all means, let the forum know that you are still waiting for a response.  However, you indicated that you wanted to correct the situation that you had.  You can do that with only using put and input.  For example:&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  want_date=put(input(have_date,mmddyy10.),mmddyy10.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art</description>
      <pubDate>Mon, 13 Sep 2010 20:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71812#M20751</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-09-13T20:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71813#M20752</link>
      <description>wouldn't mmddyy10 informat  consistently need  2 digits for month 2 digits for day and 4 for year ?&lt;BR /&gt;
&lt;BR /&gt;
The strings date I have are erratic mostly 1 digit for months till oct and 2 digits for oct,nov and dec and same is case for day single digit till 9th day of month and 2 digits from 10 till 30/31 day of the month.</description>
      <pubDate>Mon, 13 Sep 2010 20:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71813#M20752</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-13T20:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71814#M20753</link>
      <description>As demonstrated in the SAS program below, the answer is no.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
5    data _null_;&lt;BR /&gt;
6    dt = input('1/1/2010',mmddyy10.);&lt;BR /&gt;
7    put dt= date9. dt= mmddyy10.;&lt;BR /&gt;
8    run;&lt;BR /&gt;
&lt;BR /&gt;
dt=01JAN2010 dt=01/01/2010&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 second</description>
      <pubDate>Mon, 13 Sep 2010 22:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71814#M20753</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-13T22:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71815#M20754</link>
      <description>I agree with Scott.  Try the following:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
  input have_date $10.;&lt;BR /&gt;
  format date date9.;&lt;BR /&gt;
  date=input(have_date,mmddyy10.);&lt;BR /&gt;
  cards;&lt;BR /&gt;
7/1/2010&lt;BR /&gt;
06/5/2009&lt;BR /&gt;
04/05/2010&lt;BR /&gt;
5/06/2010&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Tue, 14 Sep 2010 00:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71815#M20754</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-09-14T00:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71816#M20755</link>
      <description>If not the most appropiate, the perl parsing solution is interesting.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA try;&lt;BR /&gt;
INPUT dt $CHAR40.  ;&lt;BR /&gt;
length text $10. ;&lt;BR /&gt;
retain txt;&lt;BR /&gt;
if _n_ eq 1 then txt= prxparse( 's/(?&amp;lt;!\d)(\d)\//0$1\//');&lt;BR /&gt;
text = prxchange(txt, -1, dt);&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
6/07/2009&lt;BR /&gt;
6/7/2010&lt;BR /&gt;
12/8/2008&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
/(?&amp;lt;!\d)(\d)/ matches any occurrence of digit that does not follow a digit. &lt;BR /&gt;
&lt;BR /&gt;
/(?&amp;lt;!\d)(\d)\// matches any occurrence of digit that does not follow a digit and that is&lt;BR /&gt;
followed by a slash.

Message was edited by: sensas</description>
      <pubDate>Tue, 14 Sep 2010 10:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71816#M20755</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-14T10:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71817#M20756</link>
      <description>My apologies. Don't mean to make this complex. How about if you have datetime. (I am using SAS 9.1.3)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
input have_date $18.;&lt;BR /&gt;
format date date9.;&lt;BR /&gt;
date=input(have_date,datetime16.);&lt;BR /&gt;
cards;&lt;BR /&gt;
7/1/2010:12:57&lt;BR /&gt;
06/5/2009:10:57&lt;BR /&gt;
04/05/2010:9:48&lt;BR /&gt;
5/06/2010:6:48&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
or &lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
input have_date $18.;&lt;BR /&gt;
format date date9.;&lt;BR /&gt;
date=input(have_date,datetime16.);&lt;BR /&gt;
cards;&lt;BR /&gt;
7/1/2010 12:57&lt;BR /&gt;
06/5/2009 10:57&lt;BR /&gt;
04/05/2010 9:48&lt;BR /&gt;
5/06/2010 6:48&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Datetime is not being read properly&lt;BR /&gt;
Result (from first prog)&lt;BR /&gt;
&lt;BR /&gt;
                                &lt;BR /&gt;
                              Obs       have_date            date&lt;BR /&gt;
&lt;BR /&gt;
                               1     7/1/2010:12:57             .&lt;BR /&gt;
                               2     06/5/2009:10:57            .&lt;BR /&gt;
                               3     04/05/2010:9:48            .&lt;BR /&gt;
                               4     5/06/2010:6:48             .&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
According to SAS : The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time). In the date&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Pdogra

Message was edited by: Pdogra</description>
      <pubDate>Tue, 14 Sep 2010 12:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71817#M20756</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-14T12:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71818#M20757</link>
      <description>Hi Sensas,&lt;BR /&gt;
Thanks the code works. There is bit of complexity. I have time peice attached to date as well.  what peice shall I change in the code to make it work.&lt;BR /&gt;
&lt;BR /&gt;
Data looks like:&lt;BR /&gt;
6/7/2010 12:56:08.56&lt;BR /&gt;
10/5/2010 5:46&lt;BR /&gt;
10/5/2010 15:46:09&lt;BR /&gt;
&lt;BR /&gt;
I am not an expert, but looks like I may have to write a line to handle digits before colon : &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA try;&lt;BR /&gt;
INPUT dt $CHAR40. ;&lt;BR /&gt;
length text $10. ;&lt;BR /&gt;
retain txt;&lt;BR /&gt;
if _n_ eq 1 then txt= prxparse( 's/(?</description>
      <pubDate>Tue, 14 Sep 2010 12:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71818#M20757</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-14T12:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71819#M20758</link>
      <description>The code works with or without time pieces because the reg expression just looks for alone digit followed by a slash.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
You just have to change the &lt;I&gt;text&lt;/I&gt; variable length :&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA try;&lt;BR /&gt;
INPUT dt $CHAR40. ;&lt;BR /&gt;
length text &lt;B&gt;$40.&lt;/B&gt; ;&lt;BR /&gt;
retain txt;&lt;BR /&gt;
if _n_ eq 1 then txt= prxparse( 's/(?&amp;lt;!\d)(\d)\//0$1\//');&lt;BR /&gt;
text = prxchange(txt, -1, dt);&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
6/7/2010 12:56:08.56&lt;BR /&gt;
10/5/2010 5:46&lt;BR /&gt;
10/5/2010 15:46:09&lt;BR /&gt;
;</description>
      <pubDate>Tue, 14 Sep 2010 13:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71819#M20758</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-14T13:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71820#M20759</link>
      <description>With a few changes to the reg expression you can also change time pieces :&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA try;&lt;BR /&gt;
INPUT dt $CHAR40. ;&lt;BR /&gt;
length text $40. ;&lt;BR /&gt;
retain txt;&lt;BR /&gt;
if _n_ eq 1 then txt= prxparse( 's/(?&amp;lt;!\d)(\d(?:\/|:))/0$1/');&lt;BR /&gt;
text = prxchange(txt, -1, dt);&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
6/7/2010 12:56:08.56&lt;BR /&gt;
10/5/2010 5:46&lt;BR /&gt;
10/5/2010 15:46:09&lt;BR /&gt;
; &lt;BR /&gt;
&lt;BR /&gt;
5:46 will be changed into 05:46&lt;BR /&gt;
&lt;BR /&gt;
A perl regexp documentation link : &lt;A href="http://perldoc.perl.org/perlre.html" target="_blank"&gt;http://perldoc.perl.org/perlre.html&lt;/A&gt;&lt;BR /&gt;
Be carefull: SAS doesn't implement perl syntaxe in its whole...</description>
      <pubDate>Tue, 14 Sep 2010 13:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71820#M20759</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-14T13:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71821#M20760</link>
      <description>Thank you very much Sensas.&lt;BR /&gt;
&lt;BR /&gt;
Could you please piont me to documentation to help augment my knowledge with Regex ?&lt;BR /&gt;
&lt;BR /&gt;
Also what would be significance of &lt;B&gt;!&lt;/B&gt;  and &lt;B&gt;|&lt;/B&gt; in your code.&lt;BR /&gt;
if _n_ eq 1 then txt= prxparse( 's/(?</description>
      <pubDate>Tue, 14 Sep 2010 14:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71821#M20760</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-14T14:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71822#M20761</link>
      <description>Two last points regarding a non-PERL solution, but ones which you will need to take into account with either approach: (1) you can't format a datetime with a date format and (2) if you ultimately want to input the datetimes as SAS datetime formatted variables, they will have to be structured in a way that one of the informats can be used.&lt;BR /&gt;
&lt;BR /&gt;
The following, I think, does that for the sample data you provided:&lt;BR /&gt;
&lt;BR /&gt;
options datestyle=mdy;&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
  input have_date $18.;&lt;BR /&gt;
  format date date9.;&lt;BR /&gt;
  date=datepart(input(have_date||":00:00",anydtdtm20.));&lt;BR /&gt;
  cards;&lt;BR /&gt;
7/1/2010:12:57&lt;BR /&gt;
06/5/2009:10:57&lt;BR /&gt;
04/05/2010:9:48&lt;BR /&gt;
5/06/2010:6:48&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Tue, 14 Sep 2010 14:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71822#M20761</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-09-14T14:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71823#M20762</link>
      <description>Not sure the relevance, but a DATETIME variable (seconds since 1/1/1960) can be formatted to only display the date-portion, as shown below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
9    data _null_;&lt;BR /&gt;
10   x = datetime();&lt;BR /&gt;
11   put x= datetime7. x=datetime9.;&lt;BR /&gt;
12   run;&lt;BR /&gt;
&lt;BR /&gt;
x=14SEP10 x=14SEP2010&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 second&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The important point to emphasize here is that you have limited sorting/display control over a character-formatted DATE and/or DATETIME character-string; also consider that it may not even be legitimate - yet another reason to run it through a SAS-standard INFORMAT rather than a band-aid approach using PERL, which frankly makes the eyes on my mouse-cursor roll back when I see the command/function syntax.  The best approach here is to use the INPUT function with an appropriate SAS INFORMAT, and let SAS decide if the character-string is or is not a validate numeric DATE or DATETIME value.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 14 Sep 2010 15:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71823#M20762</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-14T15:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71824#M20763</link>
      <description>&lt;I&gt;(?&amp;lt;!pattern)&lt;BR /&gt;
&lt;BR /&gt;
A zero-width negative look-behind assertion. For example /(?&amp;lt;!bar)foo/ matches any occurrence of "foo" that does not follow "bar". Works only for fixed-width look-behind.&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
Source: perl documentation&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The "!" means "not", "&amp;lt;" means "back" and ? means "is ?".&lt;BR /&gt;
&lt;BR /&gt;
So you can translate  (?&amp;lt;!pattern) by "Is the pattern not preceding ?" If it's true then you are sure "pattern" is not preceding what you're looking for.&lt;BR /&gt;
&lt;BR /&gt;
"|" is the or operator. &lt;BR /&gt;
In that expression : "&lt;B&gt;\d(?:\/|:)&lt;/B&gt;", i search for a digit that would be followed imediately by &lt;B&gt;\&lt;/B&gt; OR  &lt;B&gt;:&lt;/B&gt;.&lt;BR /&gt;
&lt;BR /&gt;
You can search for SAS documentation on perl expression by googleying "site:sas.com SUGI Perl"</description>
      <pubDate>Tue, 14 Sep 2010 15:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71824#M20763</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-14T15:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71825#M20764</link>
      <description>Appreciate your help sensas.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
PD</description>
      <pubDate>Tue, 14 Sep 2010 19:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71825#M20764</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-14T19:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71826#M20765</link>
      <description>Hi Sensas,&lt;BR /&gt;
&lt;BR /&gt;
I played with regex little bit, but I guess I am no way closer to your level of expertise. &lt;BR /&gt;
&lt;BR /&gt;
I am  trying 2 things&lt;BR /&gt;
1) Look for milliseconds from the time part and remove it e.g.&lt;BR /&gt;
12/9/2010 18:06:54.55 (remove .55)&lt;BR /&gt;
2) Look for seconds if not found then append :00 (e.g. 12/9/2010 18:064 to 12/9/2010 18:06:00 )&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to do in the same line ? Sorry don't mean to make you do my job. I am sure by the time I wil figure this out , you would have a solution for it..&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
Here's your code:&lt;BR /&gt;
&lt;BR /&gt;
DATA try;&lt;BR /&gt;
INPUT dt $CHAR40. ;&lt;BR /&gt;
length text $40. ;&lt;BR /&gt;
retain txt;&lt;BR /&gt;
if _n_ eq 1 then txt= prxparse( 's/(?</description>
      <pubDate>Wed, 15 Sep 2010 14:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71826#M20765</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-15T14:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71827#M20766</link>
      <description>Hey Fellow SAS_Forum_Campers,&lt;BR /&gt;
&lt;BR /&gt;
Is this a SAS forum or a Perl forum?&lt;BR /&gt;
&lt;BR /&gt;
After converting a character-string to a SAS DATETIME variable (seconds since 1/1/1960), you can use the SAS DATETIME format or you can extract the time-portion using the SAS CALL function TIMEPART.  See below.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
22   data _null_;&lt;BR /&gt;
23   dt = input('1/31/2009',mmddyy10.);&lt;BR /&gt;
24   dttm = dhms(dt,9,9,9.222);&lt;BR /&gt;
25   tm = timepart(dttm);&lt;BR /&gt;
26   put dt= date9. dttm= datetime7. dttm=datetime9. tm= time12.3;&lt;BR /&gt;
27   run;&lt;BR /&gt;
&lt;BR /&gt;
dt=31JAN2009 dttm=31JAN09 dttm=31JAN2009 tm=9:09:09.222&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 second&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search arguments, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
using sas dates site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
datetime date introduction site:sas.com</description>
      <pubDate>Wed, 15 Sep 2010 15:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71827#M20766</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-15T15:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71828#M20767</link>
      <description>Thanks Sbb.&lt;BR /&gt;
&lt;BR /&gt;
Well I could also do a substr to carry out the tasks but I am trying to utilise the power of regular expressions and that's very reason why SAS has included that.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
PD</description>
      <pubDate>Wed, 15 Sep 2010 18:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71828#M20767</guid>
      <dc:creator>Pdogra</dc:creator>
      <dc:date>2010-09-15T18:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE or RXCHANGE for String Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71829#M20768</link>
      <description>Okay, so after you have corrected the format, then what?  How will you know that the date, for example, 02/29/2010, is or is not valid?  Then, what will you do with the string, if sorting "by chronological date" is needed?  This is my point.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
13   data _null_;&lt;BR /&gt;
14   dt = input('02/29/2010',mmddyy10.);&lt;BR /&gt;
15   put dt= date.;&lt;BR /&gt;
16   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Invalid argument to function INPUT at line 14 column 6.&lt;BR /&gt;
dt=.&lt;BR /&gt;
dt=. _ERROR_=1 _N_=1&lt;BR /&gt;
NOTE: Mathematical operations could not be performed at the following places. The results of&lt;BR /&gt;
      the operations have been set to missing values.&lt;BR /&gt;
      Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;
      1 at 14:6&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds</description>
      <pubDate>Wed, 15 Sep 2010 18:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PRXCHANGE-or-RXCHANGE-for-String-Dates/m-p/71829#M20768</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-15T18:34:02Z</dc:date>
    </item>
  </channel>
</rss>

