<?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: Match and Value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453530#M114609</link>
    <description>&lt;P&gt;I understand that you want both the number and the unit. The something like this may work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  text='.25 Mg Every 3 Hours Prn';
  prxid=prxparse('/([0-9\.]+)\s+(Meq|mg|ml|gram(\w)*|gm|mcg)/i');
  if prxmatch(prxid,text) then do;
    number=prxposn(prxid,1,text);
    unit=prxposn(prxid,2,text);
    end;
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The PRXPOSN function returns the string inside a capture buffer (the stuff inside the parantheses).&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2018 12:57:34 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2018-04-12T12:57:34Z</dc:date>
    <item>
      <title>Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453345#M114550</link>
      <description>&lt;P&gt;&lt;BR /&gt;Text&lt;BR /&gt;.25 Mg Every 3 Hours Prn&lt;BR /&gt;&lt;BR /&gt;MATCH=prxmatch('m/Meq|mg|ml|gram(\w)*|gm|mcg/i',text);&lt;BR /&gt;&lt;BR /&gt;The result of match is 5. But I would like to capture Mg as value&amp;nbsp; in a new column as below&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Text&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Match&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;.25 Mg Every 3 Hours Prn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mg&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 19:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453345#M114550</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2018-04-11T19:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453347#M114551</link>
      <description>&lt;P&gt;I'm using SCAN and SUBSTR, but it may change depending on how you data flows. PRXMATCH gives you the position and you can use that values in SUBSTR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MATCH=SCAN(SUBSTR(TEXT,prxmatch('m/Meq|mg|ml|gram(\w)*|gm|mcg/i',text)),1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 19:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453347#M114551</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-11T19:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453363#M114552</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;How about to capture the digits that precede the keywords. in the example&amp;nbsp; .25&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 20:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453363#M114552</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2018-04-11T20:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453368#M114553</link>
      <description>&lt;P&gt;Something like this would work, also if you want to convert into numeric use INPUT function. I'm assuming value is separated from units with a space here, if not all the time in your data then change accordingly.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Text ="Example text .25 Mg Every 3 Hours Prn";
MATCH=SCAN(SUBSTR(TEXT,prxmatch('m/Meq|mg|ml|gram(\w)*|gm|mcg/i',text)),1);
value=SCAN(SUBSTR(TEXT,1,prxmatch('m/Meq|mg|ml|gram(\w)*|gm|mcg/i',text)-2),-1,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Apr 2018 20:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453368#M114553</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-11T20:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453530#M114609</link>
      <description>&lt;P&gt;I understand that you want both the number and the unit. The something like this may work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  text='.25 Mg Every 3 Hours Prn';
  prxid=prxparse('/([0-9\.]+)\s+(Meq|mg|ml|gram(\w)*|gm|mcg)/i');
  if prxmatch(prxid,text) then do;
    number=prxposn(prxid,1,text);
    unit=prxposn(prxid,2,text);
    end;
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The PRXPOSN function returns the string inside a capture buffer (the stuff inside the parantheses).&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 12:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453530#M114609</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-04-12T12:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453539#M114617</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Text ="Example text .25 Mg Every 3 Hours Prn";
pid=prxparse('m/Meq|mg|ml|gram(\w)*|gm|mcg/i');
call prxsubstr(pid,text,p,l);
if p then want=substr(text,p,l);
run;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2018 13:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453539#M114617</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-12T13:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Match and Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453561#M114629</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;if the number is 0.25, the decimal is not captured. shows as 25&lt;/DIV&gt;if there numbers are like .63-0.125 mg,&amp;nbsp; .63-0.125 are not captured.,shows as 125&lt;/DIV&gt;&lt;P&gt;if there is no space between digit and unit like 0.25Mg nothing is captured&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 14:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-and-Value/m-p/453561#M114629</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2018-04-12T14:06:29Z</dc:date>
    </item>
  </channel>
</rss>

