<?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: Extract a sequence of 16 digits from a larger string in a variable position? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674983#M203304</link>
    <description>&lt;P&gt;Yes,&lt;/P&gt;
&lt;P&gt;In the historical data, sometimes a record number was manually entered that does not conform to the norm. It will be a singular alphanumeric digit of variable length. The size of all of those is under 16 digits. They are few and far between and I would be able to reconcile those after the fact.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By extracting the 16 digit value i am seeking and populating the new column, any blanks remaining in the new column would be non conforming data from the original source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Aug 2020 12:54:57 GMT</pubDate>
    <dc:creator>smilbuta</dc:creator>
    <dc:date>2020-08-06T12:54:57Z</dc:date>
    <item>
      <title>Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674845#M203247</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;
&lt;P&gt;I am working on data cleanup project and i have come across a item i am not sure how to tackle.&lt;/P&gt;
&lt;P&gt;I have a data set with 5 columns, I need to retain 4 of them as is, but one of them I need to extract the largest string from.&lt;/P&gt;
&lt;P&gt;In most cases this string is a 16 digit record number.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The field will look like this, (the value i want is 'X')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Column Cell [AAAAAA XXXXXXXXXXXXXXXX BBBBBB]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or [XXXXXXXXXXXXXXXX AAAAAA BBBBBB]&lt;/P&gt;
&lt;P&gt;Or [AAAAAA BBBBBB XXXXXXXXXXXXXXXX]&lt;/P&gt;
&lt;P&gt;The 16 digit number can be in any of the three positions... (dont ask, legacy bookeeping)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And some times the same field will be dirty data with some random value entered as a place holder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the best way to extract that 16 digit X&amp;nbsp; field from my data column and place it in a new column?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 19:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674845#M203247</guid>
      <dc:creator>smilbuta</dc:creator>
      <dc:date>2020-08-05T19:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674849#M203249</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  string = 'AAAAAA XXXXXXXXXXXXXXXX BBBBBB';
  do i = 1 to countw(string);
    if length(scan(string, i)) = 16 then wanted_word = scan(string, i);
  end;
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Aug 2020 20:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674849#M203249</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-08-05T20:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674858#M203251</link>
      <description>&lt;P&gt;Are&amp;nbsp; A and B numbers too or is X the only digit?&amp;nbsp; Are the brackets part of the string?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 20:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674858#M203251</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-08-05T20:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674868#M203252</link>
      <description>&lt;P&gt;A and B are alpha numeric, X is a numeric value.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 21:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674868#M203252</guid>
      <dc:creator>smilbuta</dc:creator>
      <dc:date>2020-08-05T21:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674883#M203260</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  input STRING :&amp;amp;$32.;
  DIGITS=prxchange('s/(?:\w{6} (\d{16}) \w{6}|\w{6} \w{6} (\d{16})|(\d{16}) \w{6} \w{6}|.*)/\1\2\3/',1,STRING);
  cards;
ssssss 6676543456545678 llllll
llllll ssssss 6676543456545678
6676543456545678 ssssss llllll
ssssss 643456545678 llllll    
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.T" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;STRING&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DIGITS&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;ssssss 6676543456545678 llllll&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;6676543456545678&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;llllll ssssss 6676543456545678&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;6676543456545678&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;6676543456545678 ssssss llllll&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;6676543456545678&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;&lt;FONT face="courier new,courier"&gt;ssssss 643456545678 llllll&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 01:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674883#M203260</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-08-06T01:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674968#M203295</link>
      <description>&lt;PRE&gt;data WANT;
  input STRING :&amp;amp;$32.;
  p=prxmatch('/\d{16}/',string);
  if p then DIGITS=substr(string,p,16);
  drop p ;
  cards;
ssssss 6676543456545678 llllll
llllll ssssss 6676543456545678
6676543456545678 ssssss llllll
ssssss 643456545678 llllll    
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Aug 2020 11:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674968#M203295</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-06T11:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674977#M203302</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19508"&gt;@smilbuta&lt;/a&gt; : you wrote: "In most cases this string is a 16 digit record number." - can you explain what to extract in the other cases?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 12:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674977#M203302</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-06T12:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674983#M203304</link>
      <description>&lt;P&gt;Yes,&lt;/P&gt;
&lt;P&gt;In the historical data, sometimes a record number was manually entered that does not conform to the norm. It will be a singular alphanumeric digit of variable length. The size of all of those is under 16 digits. They are few and far between and I would be able to reconcile those after the fact.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By extracting the 16 digit value i am seeking and populating the new column, any blanks remaining in the new column would be non conforming data from the original source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 12:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/674983#M203304</guid>
      <dc:creator>smilbuta</dc:creator>
      <dc:date>2020-08-06T12:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a sequence of 16 digits from a larger string in a variable position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/675012#M203309</link>
      <description>I implemented this option and this worked perfectly!!!&lt;BR /&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;</description>
      <pubDate>Thu, 06 Aug 2020 14:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-sequence-of-16-digits-from-a-larger-string-in-a/m-p/675012#M203309</guid>
      <dc:creator>smilbuta</dc:creator>
      <dc:date>2020-08-06T14:20:21Z</dc:date>
    </item>
  </channel>
</rss>

