<?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 words from string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218713#M40306</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data have;
input x $40.;
cards;
W10 Day 1 (Study 1)
W1 Day 100 (Study x)
W Day 25
;
run;
data want;
 set have;
if prxmatch('/\s+Day\s+\d+\s+/i',x) then 
want=prxchange('s/.*\s+(Day\s+\d+)\s+.*/$1/i',-1,x);
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 May 2015 13:21:57 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-05-26T13:21:57Z</dc:date>
    <item>
      <title>Extracting words from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218711#M40304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hello All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the effective way to extract two words from the following string!? ( I need to extract &lt;STRONG&gt;Day 1&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;I can use &lt;STRONG&gt;substr(string,5,5)&lt;/STRONG&gt;, but sometimes it can be Day 100 or W1 Day 25 (Study 2) in which i need to extract &lt;STRONG&gt;Day 25&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I can also use scan function and extract 2 and&amp;nbsp; 3 words and concatenate ! Is there any function which is more robustic?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;W10 &lt;STRONG&gt;Day 1&lt;/STRONG&gt; (Study 1)&lt;/P&gt;&lt;P&gt;W1 &lt;STRONG&gt;Day 100&lt;/STRONG&gt; (Study x)&lt;/P&gt;&lt;P&gt;W &lt;STRONG&gt;Day 25 &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all your insights!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 21:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218711#M40304</guid>
      <dc:creator>SASSLICK001</dc:creator>
      <dc:date>2015-05-25T21:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218712#M40305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SCAN works well, either supplying a positive-value argument (from start-location) or negative-value (from end-location) -- will depend on the result/requirement, however there are likely multiple SAS functions that can accomplish the task.&amp;nbsp; Similarly, various SAS concatenation functions as well will apply, such as CATX, or using TRIM, possibly even COMPRESS, depending on the rqmt.&lt;/P&gt;&lt;P&gt;Scott Barry&lt;BR /&gt;SBBWorks, Inc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 22:10:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218712#M40305</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2015-05-25T22:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218713#M40306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data have;
input x $40.;
cards;
W10 Day 1 (Study 1)
W1 Day 100 (Study x)
W Day 25
;
run;
data want;
 set have;
if prxmatch('/\s+Day\s+\d+\s+/i',x) then 
want=prxchange('s/.*\s+(Day\s+\d+)\s+.*/$1/i',-1,x);
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 13:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218713#M40306</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-26T13:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218714#M40307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt; retain pid;&lt;/P&gt;&lt;P&gt; if _n_ eq 1 then pid=prxparse('/\s+Day\s+\d+\s+/i');&lt;/P&gt;&lt;P&gt; call prxsubstr(pid, x, position, length);&lt;/P&gt;&lt;P&gt; if position ne 0 then want = substr(x, position, length);&lt;/P&gt;&lt;P&gt; drop pid position length;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 13:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218714#M40307</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-26T13:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218715#M40308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Keshan for your reply, &lt;/P&gt;&lt;P&gt;whan about if we have &lt;STRONG&gt;W1 Screening &lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 14:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218715#M40308</guid>
      <dc:creator>SASSLICK001</dc:creator>
      <dc:date>2015-05-26T14:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218716#M40309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will return a missing value .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 11:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-words-from-string/m-p/218716#M40309</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-27T11:40:43Z</dc:date>
    </item>
  </channel>
</rss>

