<?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: How do i parse specific number combinations from a field in a table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912165#M359621</link>
    <description>&lt;P&gt;Something like this may do the trick:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length ID $8;
  _N_=findw(str,'ID',': .');
  if _N_ then 
    ID=compress(substr(str,_N_,14),,'DK');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The parameters for the COMPRESS function simply deletes anything that is not digits, and because ID has a length of 8, only the first 8 digits are included. You may have to modify the parameters for the FINDW function to find all occurrences of "ID" (the parameters shown are the ones needed for the example data provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;). The third parameter (14) to SUBSTR is just a guess, we do not want to scan the whole rest of the string in case somebody entered an ID with only 7 digits in it (in which case the "14" should more or less guarantee that we do not get the first digit of the ZIP code or the date added to the ID).&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2024 12:37:18 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2024-01-19T12:37:18Z</dc:date>
    <item>
      <title>How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911979#M359568</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of data with a column of text for medical information/notes. There is a 8 digit identifier that is used for each patient. An example of one patient information could be "John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID: 1234-5678"&lt;BR /&gt;I want to be able to pull out all ID information and store it as a new column in the table. however the ID format is not always the same, sometimes there could be a space like "1234 5678" or no space "12345678" or possible hyphens in different spots while always being 8 digits long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been using prxchange but it doesnt seem to be working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 15:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911979#M359568</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-01-18T15:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911981#M359569</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320430"&gt;@aasdfafafsdfsaf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will the identifier (regardless of format) always be the last item in the string, or could it be be found anywhere?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 16:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911981#M359569</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2024-01-18T16:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911982#M359570</link>
      <description>&lt;P&gt;it can be found anywhere unfortunately. there isnt really a unified format for this as everyone that fills in the information may fill it in differently. The only thing i noticed was that there is always an "ID:" beforehand or "ID"&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 16:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911982#M359570</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-01-18T16:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911983#M359571</link>
      <description>&lt;P&gt;As you look at the data, can you provide a set of rules (in words, not SAS code) that will allow someone to create a SAS program that will extract the desired information?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 16:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911983#M359571</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-18T16:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911987#M359575</link>
      <description>&lt;P&gt;I suppose it would be something like&lt;/P&gt;&lt;P&gt;1. Look for the ID in any case or ID:&lt;BR /&gt;2. look for a sequence of 8 digits after the prxmatch position of id&lt;BR /&gt;3. put the 8 digit value into a new column&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 17:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911987#M359575</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-01-18T17:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911989#M359576</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320430"&gt;@aasdfafafsdfsaf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code handled the different positions and formats in my test data. Note the little cheat:&amp;nbsp; The code creates a string of all digits found after ID, but it is placed in a variable 8 chars long, so it is only the 8 digits from the identifier that ahr kept, and following digits from telephone number etc. are discarded,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Test data;
data have;
  str = "John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID: 1234-5678"; output;
  str = "John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID 12 345678 "; output;
  str = "ID: 1234-5678 John Smith was called at telephone number (111)-222-3333 he was notified of his update."; output;
  str = "ID 12 345678. John Smith was called at telephone number (111)-222-3333 he was notified of his update."; output;
  str = "John Smith ID:1234 5678 was called at telephone number. (111)-222-3333 he was notified of his update."; output;
run;  

* Data step with intermediate results - easier to maintain;
data want1 (drop=s1 s2);
  set have;
  Length Identifier $8;
  s1 = translate(str,'    ','.-:,');
  s2 = substr(s1,index(lowcase(s1),'id '));
  Identifier = compress(s2,,'kd');
run;

* Proc sql with function calls nested for use as an expression;
* Beware! nested function calls in proc sql have a habit of returning max 200 bytes regardless of input length;
proc sql;
  create table want2 as
    select 
      str, 
      compress(substr(translate(str,'    ','.-:,'),index(lowcase(translate(str,'    ','.-:,')),'id ')),,'kd') as Identifier length=8
    from have;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Skærmbillede 2024-01-18 180300.png" style="width: 470px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92656i0D7F66D1E011E896/image-size/large?v=v2&amp;amp;px=999" role="button" title="Skærmbillede 2024-01-18 180300.png" alt="Skærmbillede 2024-01-18 180300.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 17:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/911989#M359576</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2024-01-18T17:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912026#M359587</link>
      <description>&lt;P&gt;Below an approach using RegEx.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input str $200.;
  datalines;
John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID: 1234-5678
John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID 12 345678 
ID: 1234-5678 John Smith was called at telephone number (111)-222-3333 he was notified of his update.
ID 12 345678. John Smith was called at telephone number (111)-222-3333 he was notified of his update.
John Smith ID:1234 5678 was called at telephone number. (111)-222-3333 he was notified of his update.
John Smith ID:1234 56789 was called at telephone number. (111)-222-3333 he was notified of his update.
;

data want(drop=_:);
  set have;
  length _pat_id $9 pat_id $8;
  _prxid=prxparse('/\bid[: ]+(\d([\d- ]){6,10}\d)\b/oi');
  if prxmatch(_prxid,str) then
    do;
      call prxposn(_prxid,1,_pos,_len);
      _pat_id=compress(substr(str,_pos,_len),,'kd');
      if length(_pat_id) = 8 then pat_id=_pat_id;
    end;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;For the RegEx bit&amp;nbsp;&lt;CODE class=" language-sas"&gt;{6,10}&lt;/CODE&gt;: the lower boundary is the number of digits that must exist, the higher boundary includes the additional non-digits that are allowed. If there can be only max two non-digits (dash or blank) then change the upper boundary to 8.&lt;/P&gt;
&lt;P&gt;Should there be a possibility that your text contains multiple patient id's then you would need to amend the code by adding logic for call prxnext()&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 21:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912026#M359587</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-01-18T21:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912033#M359591</link>
      <description>&lt;P&gt;Using the data provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;, you can:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Find the word "ID"&lt;/LI&gt;
&lt;LI&gt;Concatenate the next two words into the ID variable.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;A "word" below is a string of text delimited by a blank, a colon, a dash, or a period&amp;nbsp; - see the &lt;EM&gt;&lt;STRONG&gt;_delim&lt;/STRONG&gt;&lt;/EM&gt; variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input str $200.;
  datalines;
John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID: 1234-5678
John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID 12 345678 
ID: 1234-5678 John Smith was called at telephone number (111)-222-3333 he was notified of his update.
ID 12 345678. John Smith was called at telephone number (111)-222-3333 he was notified of his update.
John Smith ID:1234 5678 was called at telephone number. (111)-222-3333 he was notified of his update.
John Smith ID:1234 56789 was called at telephone number. (111)-222-3333 he was notified of his update.
;
data want (drop=_:);
  set have;

  _delim=' :-.';
  _nw=countw(str,_delim);
  do _w=1 to _nw until (scan(str,_w,_delim)='ID');
  end;
  length id $10;
  if _w&amp;lt;_nw-1 then id=catx(' ',scan(str,_w+1,_delim),scan(str,_w+2,_delim));
  put _n_= _w= id=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which produces this on the log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;_N_=1 _w=17 id=1234 5678
_N_=2 _w=17 id=12 345678
_N_=3 _w=1 id=1234 5678
_N_=4 _w=1 id=12 345678
_N_=5 _w=3 id=1234 5678
_N_=6 _w=3 id=1234 56789
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jan 2024 22:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912033#M359591</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-01-18T22:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912165#M359621</link>
      <description>&lt;P&gt;Something like this may do the trick:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length ID $8;
  _N_=findw(str,'ID',': .');
  if _N_ then 
    ID=compress(substr(str,_N_,14),,'DK');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The parameters for the COMPRESS function simply deletes anything that is not digits, and because ID has a length of 8, only the first 8 digits are included. You may have to modify the parameters for the FINDW function to find all occurrences of "ID" (the parameters shown are the ones needed for the example data provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;). The third parameter (14) to SUBSTR is just a guess, we do not want to scan the whole rest of the string in case somebody entered an ID with only 7 digits in it (in which case the "14" should more or less guarantee that we do not get the first digit of the ZIP code or the date added to the ID).&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 12:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/912165#M359621</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2024-01-19T12:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914043#M360191</link>
      <description>Thanks for the reply. I noticed another issue in some of the fields. Is there a quick work around if there are two instances of ID? if it was mentioned earlier in the text and then later on with ID: 1234 5678</description>
      <pubDate>Thu, 01 Feb 2024 16:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914043#M360191</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-02-01T16:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914044#M360192</link>
      <description>&lt;P&gt;Thanks for the reply. is there a way we can find a sequence of numbers after the mention of ID: in the text? I'm noticing in some of the text ID is mentioned twice where the 1234-5678 is only mentioned after the second ID&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 16:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914044#M360192</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-02-01T16:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914131#M360217</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320430"&gt;@aasdfafafsdfsaf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the reply. is there a way we can find a sequence of numbers after the mention of ID: in the text? I'm noticing in some of the text ID is mentioned twice where the 1234-5678 is only mentioned after the second ID&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the sample data used in below code doesn't cover all your cases then please provide amended sample data that represents the different patterns and tell us what you'd like as result (like populating multiple variables or creating multiple rows?).&lt;/P&gt;
&lt;P&gt;Below code populates additional variables and is based on SAS Docu sample found &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1obc9u7z3225mn1npwnassehff0.htm" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input str $200.;
  datalines;
John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID: 1234-5678
John Smith was called at telephone number (111)-222-3333 he was notified of his update. ID 12 345678 
ID: 1234-5678 John Smith was called at telephone number (111)-222-3333 he was notified of his update.
ID 12 345678. John Smith was called at telephone number (111)-222-3333 he was notified of his update.
John Smith ID:1234 5678 was called at telephone number. (111)-222-3333 he was notified of his update.
John Smith ID:1234 56789 was called at telephone number. (111)-222-3333 he was notified of his update.
John Smith ID:1234 56789 was called at telephone number. There is also ID: 1234-9999 available
John Smith ID:1234 5678 was called at telephone number. There is also ID: 1234-9999 available
;

data want(drop=_:);
  set have;
  array pat_id {3} $8;
  _prxid=prxparse('/\bid[: ]+(\d([\d- ]){6,10}\d)\b/oi');

  length _pat_id $9 _i _start _stop _pos _len 8;
  _start=1;
  _stop=length(str);
  call prxnext(_prxid, _start, _stop, str, _pos, _len);
  do while (_pos &amp;gt; 0);
    _pat_id = compress(substr(str, _pos, _len),,'kd');
    /* only populate pat_id if identified string contains exactly 8 digits */
    if length(_pat_id) = 8 then 
      do;
        _i=sum(_i,1);
        pat_id[_i]=_pat_id;
      end;
    call prxnext(_prxid, _start, _stop, str, _pos, _len);
  end;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1706830841443.png" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93197i99E8C091BF7FD4BA/image-dimensions/577x153?v=v2" width="577" height="153" role="button" title="Patrick_0-1706830841443.png" alt="Patrick_0-1706830841443.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 23:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914131#M360217</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-01T23:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914255#M360251</link>
      <description>Hi Patrick,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply. It the example text would be more like something "John Smith was given an id and a telephone call. ID 1234-5678" where the term ID is mentioned earlier but later on it would be recorded like showed. I want to extract this number and put it into a singular column. As far as I know do not believe there are multiple ID numbers mentioned. just the term "ID" may be mentioned multiple times before the number is given</description>
      <pubDate>Fri, 02 Feb 2024 17:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914255#M360251</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-02-02T17:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914369#M360297</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320430"&gt;@aasdfafafsdfsaf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The regular expression used in both of my answers will only match if an ID is followed by digits. For the pattern to match there must be a blank or colon between ID and the first digit, after the first digit the only characters allowed are a digit, a blank or a dash.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;\bid[: ]+(\d([\d- ]){6,10}\d)&lt;/PRE&gt;
&lt;P&gt;The existence of the word ID followed by some other characters that don't match the pattern won't influence the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what you describe now I suggest you use the code from my first answer, add to the data have step any additional lines of text (cases) where things are not working with your current code and test if that also causes issues with what I proposed (which I believe it won't).&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2024 02:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/914369#M360297</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-03T02:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/915840#M360835</link>
      <description>&lt;P&gt;Would this work in a table setting? The string i need to parse is a column within a table&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 15:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/915840#M360835</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-02-13T15:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/916008#M360874</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320430"&gt;@aasdfafafsdfsaf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Would this work in a table setting? The string i need to parse is a column within a table&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure that I understand. The sample code I've shared parses what's stored in variable &lt;EM&gt;str&lt;/EM&gt; - which would be "a column within a table";&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 07:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/916008#M360874</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-14T07:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/916200#M360916</link>
      <description>ah i was understanding it wrong. have a follow up question. How would i modify this portion of the regex to include future possible changes to ID for example like looking for text such as USERID or UID, personID with 9 or 10 digit numbers? '/\bid[: ]+(\d([\d- ]){6,10}\d)\b/oi'&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Feb 2024 21:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/916200#M360916</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2024-02-14T21:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do i parse specific number combinations from a field in a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/916261#M360932</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320430"&gt;@aasdfafafsdfsaf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;ah i was understanding it wrong. have a follow up question. How would i modify this portion of the regex to include future possible changes to ID for example like looking for text such as USERID or UID, personID with 9 or 10 digit numbers? '/\bid[: ]+(\d([\d- ]){6,10}\d)\b/oi'&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something like below should work&lt;/P&gt;
&lt;PRE&gt;'/\b(person|user|u)?id[: ]+(\d([\d- ]){9,12}\d)\b/oi'&lt;/PRE&gt;
&lt;P&gt;With RegEx details matter and it's imho best to always test them with sample data that include all your desired patterns and ideally also the ones that are close but you don't want selected - like: a blank between person and id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For&amp;nbsp;([\d- ]){9,&lt;STRONG&gt;12&lt;/STRONG&gt;}: If you want to allow for multiple blanks then the upper boundary must be &amp;gt;10&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there shouldn't be any blanks between the digits then the RegEx would need to look like:&lt;/P&gt;
&lt;PRE&gt;'/\b(person|user|u)?id[: ]+(\d{9,10}\d)\b/oi'&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2024 06:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-parse-specific-number-combinations-from-a-field-in-a/m-p/916261#M360932</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-15T06:36:02Z</dc:date>
    </item>
  </channel>
</rss>

