<?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: Using SUBSTR + FIND to extract text segment in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207542#M51534</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From your description my guess is that you substring outside the variable boundaries. (Supplying any error /warning messages helps).&lt;/P&gt;&lt;P&gt;For the length parameter try to use a combination of length() and min() function. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Jul 2015 16:23:38 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2015-07-21T16:23:38Z</dc:date>
    <item>
      <title>Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207540#M51532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello SAS community.&lt;/P&gt;&lt;P&gt;I am trying to extract a text segment based on a keyword from long, unstandardized text strings.&amp;nbsp; I need the text string to include 30 characters prior to the key word and 50 characters after the key word.&amp;nbsp; I am using the following code to do this.&amp;nbsp; The starting position of the extracted string appears to be accurate, but the end point varies dramatically.&amp;nbsp; I also get many warning notes in the log.&amp;nbsp; I've tried any number of parenthetical configurations around the FIND arguments to no avail.&amp;nbsp; Does anyone have any advice?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[jobtext is the variable that I am searching through.&amp;nbsp; Experience is the key word that I'm looking for.]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;extract= substr(jobtext,FIND(jobtext,"experience",'i')-20, FIND(jobtext,"experience",'i')+30);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Brandi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207540#M51532</guid>
      <dc:creator>BrandiLeach</dc:creator>
      <dc:date>2015-07-21T16:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207541#M51533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you are likely getting values for your extract variable but possibly not exactly what you want, correct?&lt;/P&gt;&lt;P&gt;What types of warnings are you getting?&lt;/P&gt;&lt;P&gt;Is there any pattern that actually indicates the end of the characters after the word that you want that might help?&lt;/P&gt;&lt;P&gt;It may be helpful to post some example data that demonstrates the issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207541#M51533</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-07-21T16:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207542#M51534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From your description my guess is that you substring outside the variable boundaries. (Supplying any error /warning messages helps).&lt;/P&gt;&lt;P&gt;For the length parameter try to use a combination of length() and min() function. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207542#M51534</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-07-21T16:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207543#M51535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I'm getting something, but not getting exactly what I want.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;The error message is "Invalid second argument to function SUBSTR."&amp;nbsp; This only happens when I add the '-20' after the FIND argument. &lt;/P&gt;&lt;P&gt;I am not setting the parameters outside of my variable.&amp;nbsp; The extracted portion cuts off before the end of the variable (they are verrrrry long text strings).&amp;nbsp; &lt;/P&gt;&lt;P&gt;I am thinking that the issue has to do with my adding '-20' and '+30' to the FIND argument but I don't know of another way to capture the text around my keyword.&amp;nbsp; Unfortunately there are no patterns that I can use to set an end value.&lt;/P&gt;&lt;P&gt;How would I use length and min within the FIND function?&lt;/P&gt;&lt;P&gt;Thanks for all of the feedback.&amp;nbsp; I appreciate the assistance.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207543#M51535</guid>
      <dc:creator>BrandiLeach</dc:creator>
      <dc:date>2015-07-21T16:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207544#M51536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure if I can/should post my raw data here.&amp;nbsp; I'm searching through job postings, so the text is long and free-form.&amp;nbsp; Here's an example of one of my extracts:&lt;/P&gt;&lt;P&gt;"specialty. previous experience in geriatric primary care, or icu/er rn is preferred. knowledge of medicare reimbursement and coding, etc., and electronic medical records used for documentation. excellent oral and written communication skills, experienced working in a collaborative care team environment and functioning autonomously with minimal supervision. ability to provide exceptional customer service to patients about medical home team: medical home team is a healthcare management company with a unique medical practice model; aligning office-based physicians with specia"&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207544#M51536</guid>
      <dc:creator>BrandiLeach</dc:creator>
      <dc:date>2015-07-21T16:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207545#M51537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;FIND(jobtext,"experience",'i')-20&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;If FIND() is &amp;lt; 20 then argument becomes negative. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Use ifn to return the appropriate value instead.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207545#M51537</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-21T16:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207546#M51538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, you mean just set the length of the extract variable to what I want.&amp;nbsp; Of course.&amp;nbsp; Thanks.&amp;nbsp; That works.&amp;nbsp; I'd still like to know why the original syntax is incorrect or if there's a better way to extract text around a keyword.&amp;nbsp; The error messages are arising on cases where the argument is valid (i.e.I'm not asking SAS to return a value before the beginning/after the end).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 17:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207546#M51538</guid>
      <dc:creator>BrandiLeach</dc:creator>
      <dc:date>2015-07-21T17:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR + FIND to extract text segment</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207547#M51539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Q 1. "why the original syntax is incorrect",&lt;/P&gt;&lt;P&gt;A 1. Please RTM of SUBSTR(). The third element is length of the extract, not the position of ending point.&lt;/P&gt;&lt;P&gt;Q 2. " if there's a better way",&lt;/P&gt;&lt;P&gt;A 2. Not sure about that, but there are definitely alternatives, for one, using PRX functions:&lt;/P&gt;&lt;P&gt;extract=prxchange('s/.+(.{20}experience.{30}).+/$1/io', -1, jobtext);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 17:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-SUBSTR-FIND-to-extract-text-segment/m-p/207547#M51539</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-07-21T17:57:00Z</dc:date>
    </item>
  </channel>
</rss>

