<?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: use prxparse finding  date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287908#M59287</link>
    <description>Hi PgStats,&lt;BR /&gt;the code works it ran without errors but didn't bring date. It brought in the 1st 199 character from the text box.. I noticed the date is formatted the same way in all my entries "".2016-06-07T00:16:11,, thanks for your assistance</description>
    <pubDate>Thu, 28 Jul 2016 18:38:01 GMT</pubDate>
    <dc:creator>Beto16</dc:creator>
    <dc:date>2016-07-28T18:38:01Z</dc:date>
    <item>
      <title>use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287662#M59211</link>
      <description>Hi I'm want to use paxparse to get the date from a csv file. The date is format 2016-06-26T20:44:16 I would want the output to look like this 06/27/2016 ...ThAnka for assistance</description>
      <pubDate>Wed, 27 Jul 2016 22:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287662#M59211</guid>
      <dc:creator>Beto16</dc:creator>
      <dc:date>2016-07-27T22:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287669#M59213</link>
      <description>&lt;P&gt;Why PRX?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a standard format that you can use with INPUT and DatePart? And why is the date 27, not 26?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
date_char='2016-06-26T20:44:16';
datetime_num=input(date_char, e8601dt.);
format datetime_num datetime20.;

date_want_num=datepart(datetime_num);
format date_want_num mmddyy10.;
date_want_char=put(date_want_num, mmddyys10.);

run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 22:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287669#M59213</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-27T22:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287673#M59216</link>
      <description>&lt;P&gt;There is no reason to use prxparse unless you want to cause yourself more work. Use the proper format when reading the data.&lt;/P&gt;
&lt;P&gt;To read that value it looks like you want to use an E8601DT. informat which will result in a SAS datetime value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question remains is do want to change the value of variable to only contain the date value or do you want it to stay as a datetime but only display the date portion?&lt;/P&gt;
&lt;P&gt;Is your current variable a datetime or character variable?&lt;/P&gt;
&lt;P&gt;Or do you just want a character variable but not an actual date variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's probably at least a dozen ways to do this depending on you current&amp;nbsp;value. If the value is character you could create a SAS date valued&amp;nbsp;variable with in a datastep:&lt;/P&gt;
&lt;P&gt;date = input(substr(longdatetime,1,10),yymmdd10.)&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;format date mmddyy10.&lt;/P&gt;
&lt;P&gt;If the variable is currently a datetime with an E8610 format then&lt;/P&gt;
&lt;P&gt;date=datepart(longdatetime);&lt;/P&gt;
&lt;P&gt;format date mmddyy10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 22:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287673#M59216</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-27T22:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287702#M59223</link>
      <description>&lt;P&gt;Pattern matching might be justified if the dates are embedded in text:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
dateStr = "To replace dates such as 2016-06-26T20:44:16 in text.";
date10 = prxchange("s#(\d{4})-(\d{2})-(\d{2})T[0-9:]{8}#\2/\3/\1#o", 1, dateStr);
put _all_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jul 2016 01:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287702#M59223</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-28T01:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287719#M59229</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt; T;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt; A=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#800080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#800080" face="SAS Monospace" size="1"&gt;'2016-06-26T20:44:16'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt; B=input(A,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;anydtdte10.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="1"&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="1"&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="1"&gt;putlog&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt; B &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;mmddyy.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;06/26/16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 05:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287719#M59229</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-28T05:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287908#M59287</link>
      <description>Hi PgStats,&lt;BR /&gt;the code works it ran without errors but didn't bring date. It brought in the 1st 199 character from the text box.. I noticed the date is formatted the same way in all my entries "".2016-06-07T00:16:11,, thanks for your assistance</description>
      <pubDate>Thu, 28 Jul 2016 18:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287908#M59287</guid>
      <dc:creator>Beto16</dc:creator>
      <dc:date>2016-07-28T18:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287918#M59290</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71899"&gt;@Beto16&lt;/a&gt; wrote:&lt;BR /&gt;Hi PgStats,&lt;BR /&gt;the code works it ran without errors but didn't bring date. It brought in the 1st 199 character from the text box.. I noticed the date is formatted the same way in all my entries&lt;STRONG&gt; "".2016-06-07T00:16:11,,&lt;/STRONG&gt; thanks for your assistance&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you now saying that the data field starts with quotes and has a period before the value?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 19:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287918#M59290</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-28T19:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287967#M59311</link>
      <description>Yes that is how all date entries look "".2016-06-07T00:16:11,, thanks for your assistance</description>
      <pubDate>Thu, 28 Jul 2016 21:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/287967#M59311</guid>
      <dc:creator>Beto16</dc:creator>
      <dc:date>2016-07-28T21:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288009#M59336</link>
      <description>&lt;P&gt;Well then use SUBSTR to extract the relevant char portion and use any of the above solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SUBSTR is a fairly self explanatory function.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2016 00:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288009#M59336</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-29T00:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288017#M59340</link>
      <description>The "".2016-06-07T00:16:11,, is not in the same location in the comment box it varies ...would substr still work ? The prxchange actually comes close to what I need&lt;BR /&gt;data test;&lt;BR /&gt;Date10 = prxchange("s#(\d{4})-(\d{2})-(\d{2})T[0-9:]{8}#\2/\3/\1#o", 1, dateStr); put _all_; run;&lt;BR /&gt;&lt;BR /&gt;It doesn't bring date .. thanks for the help&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Jul 2016 01:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288017#M59340</guid>
      <dc:creator>Beto16</dc:creator>
      <dc:date>2016-07-29T01:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288019#M59342</link>
      <description>&lt;P&gt;This will extract the date only, in mmddyy10. format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
dateStr = "To extract dates such as 2016-06-26T20:44:16 from almost any text.";
date10 = prxchange("s#.*(\d{4})-(\d\d)-(\d\d)T[0-9:]{8}.*#\2/\3/\1#o", 1, dateStr);
put dateStr = / date10 = ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jul 2016 02:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288019#M59342</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-29T02:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288026#M59345</link>
      <description>&lt;P&gt;You can make a custom regex informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;               proc format;

 invalue anynum (default=24)

 's/.*?              (?# lazy match of any character     )
    (               (?# 1st capture group               )
     \d{4}-         (?# 4 digits [year]                 )
     \d{2}-         (?# 2 digits [month]                )
     \d{2}          (?# 2 digits [day]                  )
    )               (?# close 1st capture group         )
    .*?             (?# lazy match of any character     )  
    /\1/x'         %*  keep date. type text   ;
                                               (regexpe)= [yymmdd10.] 

 other                                                  = .;

run;     
        
data _null_; 
  input X anynum.;
  putlog 'Date= ' X date9.  ; 
cards;
".2016-06-07T00:16:11
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Date= 07JUN2016&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simplified from multi-regex informat example taken from:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.amazon.com/High-Performance-SAS-Coding-Christian-Graffeuille/dp/1512397490" target="_self"&gt;High-Performance SAS Coding&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.amazon.com/High-Performance-SAS-Coding-Christian-Graffeuille/dp/1512397490" target="_blank"&gt;https://www.amazon.com/High-Performance-SAS-Coding-Christian-Graffeuille/dp/1512397490&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2016 02:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288026#M59345</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-29T02:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288032#M59348</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71899"&gt;@Beto16&lt;/a&gt; wrote:&lt;BR /&gt;The "".2016-06-07T00:16:11,, is not in the same location in the comment box it varies ...would substr still work ?&lt;/BLOCKQUOTE&gt;


No where in your previous comments does it say you were dealing with text in a comment field. Please take the time to describe your problem so the appropriate solution can be suggested.</description>
      <pubDate>Fri, 29 Jul 2016 03:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288032#M59348</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-29T03:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: use prxparse finding  date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288110#M59360</link>
      <description>Hi Chris you help me with this code couple of weeks ago Thanks it works now the request is to find Date formatted "".2016-06-07T00:16:11,,&amp;nbsp; is it possible to run this part of code&lt;BR /&gt;PRX=prxparse('/(1ZT[A-Z\d]{14}) an where it matches 1ZT Bring in everything in the 10 character to the left of 1ZT ? the date is always in front of the 1ZT your thoughts?&lt;BR /&gt;&lt;BR /&gt;data _null_; file "%sysfunc(pathname(WORK))\t.txt"; X='X. Bacode. N. Newvar ZT2487 '; put X; X='Blah,blah,blah, Atmbarcode :"TY272822. 2'; put X; X='Blah, blah,blah,blah, '; put X; X='1ZT2487A122111112,blah,blah, '; put X; run; data WANT; infile "%sysfunc(pathname(WORK))\t.txt" pad; input X $80.; PRX=prxparse('/(1ZT[A-Z\d]{14}) (?# capture 1ZT and 14 letters or digits) | (?# or) (?&amp;lt;=Atmbarcode\W{3}) (?# capture preceeded by Atmbarcode\W{3} ) (TY\d*) (?# capture TY and digits) /x'); call prxsubstr(PRX,X,POS,LEN); if POS then STR=substr(X,POS,LEN); putlog STR=; run;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;STR=&lt;BR /&gt;&lt;BR /&gt;STR=TY272822&lt;BR /&gt;&lt;BR /&gt;STR=&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Jul 2016 13:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-prxparse-finding-date/m-p/288110#M59360</guid>
      <dc:creator>Beto16</dc:creator>
      <dc:date>2016-07-29T13:25:19Z</dc:date>
    </item>
  </channel>
</rss>

