<?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 the substring in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130217#M10652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a reason why each extracted comment has to be a specified number of characters? Unless your original comment field is neatly separated by number of characters (e.g. the first sub-comment always ends at 240, the second always ends at 480, etc), the results are going to be less than desireable -- as it seems you've discovered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are trying to break a large comment field into smaller fields, it might make more sense to break it up based on natural sentence endings (e.g. period, question mark, exclamation mark).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Sep 2013 18:41:11 GMT</pubDate>
    <dc:creator>Fugue</dc:creator>
    <dc:date>2013-09-05T18:41:11Z</dc:date>
    <item>
      <title>Extracting words from the substring</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130216#M10651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have a very long varying character field named comment. I want break that field into 7 fields.&lt;/P&gt;&lt;P&gt;and I use &lt;/P&gt;&lt;P&gt; comment_one = substr(comment,1,240);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; comment_extraone = substr(comment,241,480);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; comment_extratwo = substr(comment,481,720);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; comment_extrathree = substr(comment,721,960);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; comment_extrafour = substr(comment,961,1200);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; comment_extrafive=substr(comment,1201,1440);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; comment_extrasix = substr(comment,1441,1680);&lt;/P&gt;&lt;P&gt;but extracted substring looked like "I went to football game ..............then I reached ho"&lt;/P&gt;&lt;P&gt;since the length of comment_one is 240 it showed "ho" as last word but it is actually "home".&lt;/P&gt;&lt;P&gt;I am wondering if there is a way to fix this. Index function does not work since each comment&lt;/P&gt;&lt;P&gt;is of different length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 17:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130216#M10651</guid>
      <dc:creator>learner_sas</dc:creator>
      <dc:date>2013-09-05T17:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from the substring</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130217#M10652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a reason why each extracted comment has to be a specified number of characters? Unless your original comment field is neatly separated by number of characters (e.g. the first sub-comment always ends at 240, the second always ends at 480, etc), the results are going to be less than desireable -- as it seems you've discovered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are trying to break a large comment field into smaller fields, it might make more sense to break it up based on natural sentence endings (e.g. period, question mark, exclamation mark).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 18:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130217#M10652</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-09-05T18:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from the substring</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130218#M10653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So would it be fair to say you want to split the comment by punctuation? Your could do something like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length comment_1 - comment_7 $ 100;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_1 = scan(comment,1,".","RP");&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_2 = scan(comment,2,".","RP");&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_3 = scan(comment,3,".","RP");&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_4 = scan(comment,4,".","RP");&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_5 = scan(comment,5,".","RP");&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_6 = scan(comment,6,".","RP");&lt;/P&gt;&lt;P&gt;&amp;nbsp; comment_7 = scan(comment,7,".","RP");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code could be condensed with an arrary and do loop but I left it alone as to not confuse matters. The R and P are optional modifiers that trim leading and trailing spaces from the result (R) and use all punctuation as delimiters (P).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 18:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130218#M10653</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-09-05T18:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from the substring</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130219#M10654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am transferring this extracted sub strings into Crystal cell and it has 256 as maximum character length. I am trying to fit as much as possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 18:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130219#M10654</guid>
      <dc:creator>learner_sas</dc:creator>
      <dc:date>2013-09-05T18:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from the substring</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130220#M10655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This reminds me of the good old days before PROC REPORT performed all the text-wrapping for you.&amp;nbsp; Here's an approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array extra {6} $240 comment_extra1 - comment_extra6;&lt;/P&gt;&lt;P&gt;dum = comment;&lt;/P&gt;&lt;P&gt;drop dum;&lt;/P&gt;&lt;P&gt;_i_=0;&lt;/P&gt;&lt;P&gt;if dum &amp;gt; ' ' then do until (dum=' ');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do _k_=241 to 1 by -1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(dum, _k_, 1) = ' ' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _i_ + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extra{_i_} = substr(dum, 1, _k_-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dum = left(substr(dum, k));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's up to you to make sure that 6 variables is enough.&amp;nbsp; Sometimes an individual word can be quite lengthy.&amp;nbsp; In one medical dictionary that I examined, several words were each over 40 characters long.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 19:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130220#M10655</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-09-05T19:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting words from the substring</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130221#M10656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another approach. It hasn't been exhaustively tested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt; input;&lt;BR /&gt; LongDataRecord = _infile_;&lt;BR /&gt; cards;&lt;BR /&gt;Long text string 1&lt;BR /&gt;Long text string 2&lt;BR /&gt;Long text string 3&lt;BR /&gt;Long text string 4&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want(keep=ShortDataRecord);&lt;BR /&gt; length ShortDataRecord $256;&lt;BR /&gt; retain prxid;&lt;/P&gt;&lt;P&gt; if _n_=1 then&lt;BR /&gt;&amp;nbsp; prxid=prxparse('/\s+\S*$/o');&lt;BR /&gt; set have;&lt;BR /&gt; length TestPart $257;&lt;/P&gt;&lt;P&gt; do while(^missing(LongDataRecord));&lt;BR /&gt;&amp;nbsp; TestPart = substr(LongDataRecord, 1, 257);&lt;BR /&gt;&amp;nbsp; FoundPosn = prxmatch(prxid, TestPart);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if FoundPosn &amp;gt; 0 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastChar = FoundPosn - 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstChar = FoundPosn + 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ShortDataRecord = substr(LongDataRecord, 1, LastChar);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LongDataRecord = left(substrn(LongDataRecord, FirstChar));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ShortDataRecord = substr(LongDataRecord, 1, 256);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LongDataRecord = left(substrn(257, 1));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 20:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Extracting-words-from-the-substring/m-p/130221#M10656</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2013-09-05T20:06:08Z</dc:date>
    </item>
  </channel>
</rss>

