<?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: regular expressions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22014#M3565</link>
    <description>Thnaks yoba!</description>
    <pubDate>Thu, 23 Apr 2009 15:09:19 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-04-23T15:09:19Z</dc:date>
    <item>
      <title>regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22011#M3562</link>
      <description>I'm not that good at reg exp. I tried my luck ..was not sucessful. Need your help on this.  &lt;BR /&gt;
&lt;BR /&gt;
I have a filed called "Drug_name". It will have the list of drugs. example: Paracetmol 4.8MG VIAL&lt;BR /&gt;
 &lt;BR /&gt;
The task is to extract the digits from it. in this case its 4.8.&lt;BR /&gt;
 &lt;BR /&gt;
 &lt;BR /&gt;
Possible scenarios:&lt;BR /&gt;
the number of digits vary between 1 and 4&lt;BR /&gt;
so we need to have an or condition for number of digits d  d\d d\d\d d\d\d\d&lt;BR /&gt;
 &lt;BR /&gt;
and we should consider decimal also between two digits as in the example.&lt;BR /&gt;
 &lt;BR /&gt;
the values should go to the filed called strength,.&lt;BR /&gt;
 &lt;BR /&gt;
in this case strength is 4.8&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
SASphile</description>
      <pubDate>Wed, 22 Apr 2009 15:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22011#M3562</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-04-22T15:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22012#M3563</link>
      <description>Use ANYALPHA to test if non-numeric present, then use COMPRESS function to remove chars A-Z after UPCASE, in a DATA step to assign a SAS variable, then use INPUT (convert to SAS NUMERIC) and PUT function (to convert back to a "formatted" CHARACTER type variable, displayed as a number).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 22 Apr 2009 15:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22012#M3563</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-22T15:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22013#M3564</link>
      <description>Hello SASPhile,&lt;BR /&gt;
&lt;BR /&gt;
Here is how your program could look like:&lt;BR /&gt;
&lt;BR /&gt;
data T01_input;&lt;BR /&gt;
length drug $50;&lt;BR /&gt;
infile cards delimiter=',';&lt;BR /&gt;
input id drug;&lt;BR /&gt;
cards;&lt;BR /&gt;
1,Paracetmol 4.8MG VIA&lt;BR /&gt;
2,Paracetmol 423.23422238MG VIA&lt;BR /&gt;
3,Paracetmol 42342.38MG VIA&lt;BR /&gt;
4,Paracetmol x.8MG VIA&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data T02_output;&lt;BR /&gt;
set T01_input;&lt;BR /&gt;
length myDigits $50;&lt;BR /&gt;
if prxmatch('/.* \d{1,4}\.\d+MG .*/',drug)&lt;BR /&gt;
then myDigits = prxchange('s/.* (\d{1,4}\.\d+)MG .*/$1/', -1, drug);&lt;BR /&gt;
else myDigits = "NOT FOUND";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=T02_output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
You would get the following output:&lt;BR /&gt;
&lt;BR /&gt;
1     Paracetmol 4.8MG VIA              1    4.8&lt;BR /&gt;
2     Paracetmol 423.23422238MG VIA     2    423.23422238&lt;BR /&gt;
3     Paracetmol 42342.38MG VIA         3    NOT FOUND&lt;BR /&gt;
4     Paracetmol x.8MG VIA              4    NOT FOUND&lt;BR /&gt;
&lt;BR /&gt;
If you need to convert the myDigit string to number ... use the input function.&lt;BR /&gt;
&lt;BR /&gt;
Does it help?&lt;BR /&gt;
&lt;BR /&gt;
Yoba</description>
      <pubDate>Wed, 22 Apr 2009 16:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22013#M3564</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-22T16:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22014#M3565</link>
      <description>Thnaks yoba!</description>
      <pubDate>Thu, 23 Apr 2009 15:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regular-expressions/m-p/22014#M3565</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-04-23T15:09:19Z</dc:date>
    </item>
  </channel>
</rss>

