<?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: Extracting a Dollar Value from the Beginning of a Character Field Using Regular Expressions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704797#M216088</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   format ProtectedBalance dollar10.2;
   set have; 
   if _N_=1 then do; 
       retain patt1;
       pattern1="/[\$][,.\d]{1,}/";
       patt1=prxparse(pattern1); 
   end;
   call prxsubstr(patt1, case_notes, position1, length1); 
   if position1&amp;gt;0 then ProtectedBalance=substr(case_notes, position1, length1);  
   if reverse(substr(ProtectedBalance,1,1))=',' then ProtectedBalance=substr(ProtectedBalance,1, length(ProtectedBalance)-1);
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Dec 2020 16:49:32 GMT</pubDate>
    <dc:creator>vellad</dc:creator>
    <dc:date>2020-12-09T16:49:32Z</dc:date>
    <item>
      <title>Extracting a Dollar Value from the Beginning of a Character Field Using Regular Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704736#M216076</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a variable in my dataset called 'Case_Notes' that could start with a dollar value, and I want to extract that dollar value into a new variable called 'Protected Balance' if it exists. I have been directed to perl regular expressions but am getting lost and could use some help. Here is an example of what the data looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case_Notes&lt;BR /&gt;$15,229.00 , 9999999999 - known fraud&lt;BR /&gt;" 9999999999"&lt;BR /&gt;$1,740.00 , 9999999999- known fraud - calling on multiple accounts&lt;BR /&gt;$1,155.79 , 9999999999- known fraud -male fraudster calling on female account&lt;BR /&gt;$14,026.81, 9999999999 - known fraud - fraudster continues to call in&lt;BR /&gt;$12,495.00 , 9999999999- fraudster calling on multiple accounts&lt;BR /&gt;$9,936.00 , 9999999999- known fraud - young female calling as ch - true person lives in OH&lt;BR /&gt;$9,936.00 , 9999999999- known fraud - young female calling as ch - true person lives in OH&lt;BR /&gt;$5,150.00 , 9999999999- known fraud - male fraudster still calling in&lt;BR /&gt;$2,565.67 , 9999999999- Two accounts opened and different addresses. Caller stated he send docs in already.&lt;BR /&gt;$5,150.00 , 9999999999- known fraud - male fraudster still calling in&lt;BR /&gt;$5,150.00 , 9999999999- known fraud - male fraudster still calling in&lt;BR /&gt;9999999999- known fraud - ani calling in IVR on multiple accounts |3974950358 - known fraud - ani calling in IVR on multiple accounts&lt;BR /&gt;9999999999 - fraudster calling in , true person lives in SC.&lt;BR /&gt;9999999999 - known fraud - female calling on multiple accounts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Protected_Balance&lt;/P&gt;&lt;P&gt;$15,229.00&lt;BR /&gt;-&lt;BR /&gt;$1,740.00&lt;BR /&gt;$1,155.79&lt;BR /&gt;$14,026.81&lt;BR /&gt;$9,936.00&lt;BR /&gt;$9,936.00&lt;BR /&gt;$5,150.00&lt;BR /&gt;$2,565.67&lt;BR /&gt;$5,150.00&amp;nbsp;&lt;BR /&gt;$5,150.00&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My latest attempt was:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
format ProtectedBalance dollar10.2;
ProtectedBalance = prxchange('s/.*(\$\d+).*/\1/',-1,case_notes);
where Fraud_Status = 'FRAUD';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But that got me nowhere. Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 14:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704736#M216076</guid>
      <dc:creator>jmextratall</dc:creator>
      <dc:date>2020-12-09T14:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a Dollar Value from the Beginning of a Character Field Using Regular Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704797#M216088</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   format ProtectedBalance dollar10.2;
   set have; 
   if _N_=1 then do; 
       retain patt1;
       pattern1="/[\$][,.\d]{1,}/";
       patt1=prxparse(pattern1); 
   end;
   call prxsubstr(patt1, case_notes, position1, length1); 
   if position1&amp;gt;0 then ProtectedBalance=substr(case_notes, position1, length1);  
   if reverse(substr(ProtectedBalance,1,1))=',' then ProtectedBalance=substr(ProtectedBalance,1, length(ProtectedBalance)-1);
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Dec 2020 16:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704797#M216088</guid>
      <dc:creator>vellad</dc:creator>
      <dc:date>2020-12-09T16:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a Dollar Value from the Beginning of a Character Field Using Regular Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704826#M216098</link>
      <description>&lt;P&gt;Keep it simple:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length case_notes $200;
infile datalines truncover;
input Case_Notes $200.;
datalines;
$15,229.00 , 9999999999 - known fraud
" 9999999999"
$1,740.00 , 9999999999- known fraud - calling on multiple accounts
$1,155.79 , 9999999999- known fraud -male fraudster calling on female account
$14,026.81, 9999999999 - known fraud - fraudster continues to call in
$12,495.00 , 9999999999- fraudster calling on multiple accounts
$9,936.00 , 9999999999- known fraud - young female calling as ch - true person lives in OH
$9,936.00 , 9999999999- known fraud - young female calling as ch - true person lives in OH
$5,150.00 , 9999999999- known fraud - male fraudster still calling in
$2,565.67 , 9999999999- Two accounts opened and different addresses. Caller stated he send docs in already.
$5,150.00 , 9999999999- known fraud - male fraudster still calling in
$5,150.00 , 9999999999- known fraud - male fraudster still calling in
9999999999- known fraud - ani calling in IVR on multiple accounts |3974950358 - known fraud - ani calling in IVR on multiple accounts
9999999999 - fraudster calling in , true person lives in SC.
9999999999 - known fraud - female calling on multiple accounts
;

data want;
if not prxId then prxId + prxParse("/\$[0-9,.]+\d\b/");
set have;
call prxSubstr(prxId, Case_Notes, pos, len);
if pos &amp;gt; 0 then Protected_Balance = input(substr(Case_Notes, pos, len), ?? comma32.);
drop prxId pos len;
run;

proc print data=want noobs; run;&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-1607537276193.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52478iDC260F2BA3CB0E17/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1607537276193.png" alt="PGStats_0-1607537276193.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 18:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704826#M216098</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-12-09T18:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a Dollar Value from the Beginning of a Character Field Using Regular Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704872#M216119</link>
      <description>&lt;P&gt;Thank you very much for this! Worked perfectly. I appreciate the help.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 21:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-a-Dollar-Value-from-the-Beginning-of-a-Character/m-p/704872#M216119</guid>
      <dc:creator>jmextratall</dc:creator>
      <dc:date>2020-12-09T21:48:54Z</dc:date>
    </item>
  </channel>
</rss>

