<?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: how to derive third word from a string without using scan function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481048#M124384</link>
    <description>&lt;P&gt;You could use a regular expression to extract the third word from a string, see the documentation of prxparse and prxposn for details. But i don't see any reason not to use scan-function. It is faster and requires less code.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jul 2018 08:20:05 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-07-25T08:20:05Z</dc:date>
    <item>
      <title>how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481031#M124374</link>
      <description />
      <pubDate>Wed, 25 Jul 2018 07:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481031#M124374</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-25T07:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481032#M124375</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;please check below code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
x = "hello how are you";
p = anyspace(x,anyspace(x)+1);
p1 = anyspace(x,p+1);
word3 = substr(x,p,p1-p);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;manoj&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 07:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481032#M124375</guid>
      <dc:creator>s_manoj</dc:creator>
      <dc:date>2018-07-25T07:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481046#M124382</link>
      <description>&lt;P&gt;Please use the body of the thread post to describe your problem exactly.&amp;nbsp; Present test data in the form of a datastep, and show what the output should look like.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what you have posted, you would simply supply 3 to the function, e.g.:&lt;/P&gt;
&lt;PRE&gt;want=scan(have,3," ");&lt;/PRE&gt;
&lt;P&gt;I have assumed space delimiter.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 08:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481046#M124382</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-25T08:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481048#M124384</link>
      <description>&lt;P&gt;You could use a regular expression to extract the third word from a string, see the documentation of prxparse and prxposn for details. But i don't see any reason not to use scan-function. It is faster and requires less code.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 08:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481048#M124384</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-25T08:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481055#M124386</link>
      <description>&lt;P&gt;Maxim 14: use the right tool. The scan() function is the right tool, so use it.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 08:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481055#M124386</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-25T08:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481097#M124407</link>
      <description>&lt;P&gt;You've already been warned about your refusal to use SCAN.&amp;nbsp; It's like saying, "I want to dig a ditch and I have to use a spoon instead of a shovel."&amp;nbsp; Just to put that in context here ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;shows you how to use SCAN.&amp;nbsp; It works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183918"&gt;@s_manoj&lt;/a&gt;&amp;nbsp;solution avoids SCAN and uses a good set of tools, but not a foolproof set of tools.&amp;nbsp; Try using it on this sentence:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;x = "hello&amp;nbsp; how are you"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The extra blank throws off the logic and selects "how" as the third word.&amp;nbsp; So you could use an even more complex approach, or you could just use SCAN, the tool that is built for the job.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 12:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481097#M124407</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-25T12:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481099#M124408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Maxim 14: use the right tool. The scan() function is the right tool, so use it.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;OFF TOPIC VENTING&lt;/P&gt;
&lt;P&gt;I get frustrated by the number of questions asked here in the SAS Communities where the user states that a specific tool has to be used, or the user states that&amp;nbsp;the best tool not be used. I find myself replying to these questions only on rare occasions now. So Maxim 14 is a good one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;make an exception if the best tool is not in your SAS license, for example you don't have PROC IML in your SAS license, that's a different situation.&amp;nbsp;But this exception doesn't apply to SCAN.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 12:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481099#M124408</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-25T12:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481191#M124432</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;BR /&gt;yes with above sentence you have , that code might give different result,&lt;BR /&gt;If we add compbl() function to the above code, then problem would be solved</description>
      <pubDate>Wed, 25 Jul 2018 17:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481191#M124432</guid>
      <dc:creator>s_manoj</dc:creator>
      <dc:date>2018-07-25T17:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481214#M124443</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183918"&gt;@s_manoj&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I agree COMPBL would help.&amp;nbsp; I wasn't trying to pick on your solution in particular ... just trying to illustrate that SCAN eliminates complications because it is built for the job.&amp;nbsp; Even with COMPBL, you might need LEFT also.&amp;nbsp; Try adding a&amp;nbsp;leading blank and see what happens:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT size="2"&gt;x = "&lt;/FONT&gt; &lt;FONT size="2"&gt;hello how are you";&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 18:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481214#M124443</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-25T18:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to derive third word from a string without using scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481346#M124487</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;,&lt;BR /&gt;Yes I completely agree with you and that's true, it's better not to complicate code when a simple function can do. In recent days some of them were coming across these type logical questions by there superiors, so that might be the reason they were posting these type of questions, but up to they won't implement these type of complicated code in real scenarios.&lt;BR /&gt;&lt;BR /&gt;Thankyou</description>
      <pubDate>Thu, 26 Jul 2018 05:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-derive-third-word-from-a-string-without-using-scan/m-p/481346#M124487</guid>
      <dc:creator>s_manoj</dc:creator>
      <dc:date>2018-07-26T05:47:55Z</dc:date>
    </item>
  </channel>
</rss>

