<?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 Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, another? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867507#M342632</link>
    <description>&lt;P&gt;Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, another one?&lt;BR /&gt;&lt;BR /&gt;Data example;&lt;/P&gt;&lt;P&gt;char = "this_is_a_example_with_date_20230331";&lt;/P&gt;&lt;P&gt;/* The format date is YYYYMMDD */&lt;/P&gt;&lt;P&gt;resolve = ? / * function;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;resolve&lt;/P&gt;&lt;P&gt;31/03/2023&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2023 17:03:38 GMT</pubDate>
    <dc:creator>Mozer19</dc:creator>
    <dc:date>2023-03-31T17:03:38Z</dc:date>
    <item>
      <title>Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, another?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867507#M342632</link>
      <description>&lt;P&gt;Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, another one?&lt;BR /&gt;&lt;BR /&gt;Data example;&lt;/P&gt;&lt;P&gt;char = "this_is_a_example_with_date_20230331";&lt;/P&gt;&lt;P&gt;/* The format date is YYYYMMDD */&lt;/P&gt;&lt;P&gt;resolve = ? / * function;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;resolve&lt;/P&gt;&lt;P&gt;31/03/2023&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867507#M342632</guid>
      <dc:creator>Mozer19</dc:creator>
      <dc:date>2023-03-31T17:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, anoth</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867525#M342636</link>
      <description>&lt;P&gt;PRXMATCH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
char = "this_is_a_example_with_date_20230331";
pos = prxmatch("/(19|20)\d\d[01]\d[0123]\d/o", char);
if pos &amp;gt; 0 then validDate = input(substr(char,pos,8),yymmdd8.);
format validDate yymmdd10.;
drop pos;
run;

proc print;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1680284110440.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82245i6E9051E49515245E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1680284110440.png" alt="PGStats_0-1680284110440.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 17:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867525#M342636</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2023-03-31T17:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, anoth</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867535#M342639</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;, Thank you so much! Your solution solved my problem.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 18:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/867535#M342639</guid>
      <dc:creator>Mozer19</dc:creator>
      <dc:date>2023-03-31T18:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, anoth</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/868506#M343091</link>
      <description>&lt;P&gt;Hi, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;.&amp;nbsp;Are you ok?&lt;BR /&gt;I try to learn your solution's about prxmatch, what does that means (19|20) inside the function?&amp;nbsp;Exemple:&amp;nbsp;pos = prxmatch("/(19|20)\d\d[01]\d[0123]\d/o", char);&lt;BR /&gt;&lt;BR /&gt;If you explain me more about every single steps of function, like a, how the function transform 20230406 in 06-04-2023, I preciate this. Can you?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Would You to show me more a function to&amp;nbsp;return month and year?&lt;BR /&gt;And another function to return only year?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 20:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/868506#M343091</guid>
      <dc:creator>Mozer19</dc:creator>
      <dc:date>2023-04-06T20:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Witch function I can to use for search a date inside chars: PRXCHANGE, PRXMATCH, PRXPARSE, anoth</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/868546#M343114</link>
      <description>&lt;P&gt;Here is a commented version of the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
char = "this_is_a_example_with_date_20230331";
/*
The first parameter of the prxmatch function is a 
Perl regular expression. It is interpreted as follows
Find a substring that:
starts with 19 or 20, followed by two digits, followed by 0 or 1,
followed by a digit, followed by 0, 1, 2, or 3, followed by a digit.
If found, return the position of the beginning the matching substring.
*/
pos = prxmatch("/(19|20)\d\d[01]\d[0123]\d/o", char);
/*
If a match is found, extract the substring, read it as a SAS date with 
informat YYMMDD8.
*/
if pos &amp;gt; 0 then validDate = input(substr(char,pos,8),yymmdd8.);
/* 
When displaying the SAS date, use the format YYMMDD10.
*/
format validDate yymmdd10.;

drop pos;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perl regular expression syntax is described &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0s9ilagexmjl8n1u7e1t1jfnzlk.htm" target="_self"&gt;here.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;To display the date as year and month, use format YYMMD.&lt;/P&gt;
&lt;P&gt;To display the date as year only, use format YEAR4.&lt;/P&gt;
&lt;P&gt;Note that the period is part of the format name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hth&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 03:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Witch-function-I-can-to-use-for-search-a-date-inside-chars/m-p/868546#M343114</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2023-04-07T03:15:54Z</dc:date>
    </item>
  </channel>
</rss>

