<?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 Finding a word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630702#M186743</link>
    <description>&lt;P&gt;Hello everyone;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how to find for example only "&lt;SPAN&gt;&lt;STRONG&gt;ture&lt;/STRONG&gt;" in the following string"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"screen shots or pictures of errors&amp;nbsp;with &lt;STRONG&gt;ture&lt;/STRONG&gt; and ..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried many available functions, but non of them worked as they need location of the word. But since I'm dealing with over 100 milion observation and the location of the word in variable (column) is random, I can't get any useful results. For example, if I want to use index or Find or Contains, then I get&amp;nbsp;pictures and&amp;nbsp;&lt;STRONG&gt;ture, &lt;/STRONG&gt;because&amp;nbsp;pictures also contains ture. If I want to use&amp;nbsp;SUBSTR instead then I need to know the location of the word, which I don't because the word can be found anywhere in the column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be appreciated very much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Mar 2020 18:12:26 GMT</pubDate>
    <dc:creator>Behrouz</dc:creator>
    <dc:date>2020-03-09T18:12:26Z</dc:date>
    <item>
      <title>Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630702#M186743</link>
      <description>&lt;P&gt;Hello everyone;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how to find for example only "&lt;SPAN&gt;&lt;STRONG&gt;ture&lt;/STRONG&gt;" in the following string"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"screen shots or pictures of errors&amp;nbsp;with &lt;STRONG&gt;ture&lt;/STRONG&gt; and ..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried many available functions, but non of them worked as they need location of the word. But since I'm dealing with over 100 milion observation and the location of the word in variable (column) is random, I can't get any useful results. For example, if I want to use index or Find or Contains, then I get&amp;nbsp;pictures and&amp;nbsp;&lt;STRONG&gt;ture, &lt;/STRONG&gt;because&amp;nbsp;pictures also contains ture. If I want to use&amp;nbsp;SUBSTR instead then I need to know the location of the word, which I don't because the word can be found anywhere in the column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be appreciated very much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 18:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630702#M186743</guid>
      <dc:creator>Behrouz</dc:creator>
      <dc:date>2020-03-09T18:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630704#M186744</link>
      <description>&lt;P&gt;Instead of FIND, use FINDW.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 18:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630704#M186744</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-03-09T18:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630706#M186746</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
 str="screen shots or pictures of errors with ture and ...";
 position_of_the_word=findw(str,'ture',' ','e');
 extract_the_word=scan(str,findw(str,'ture',' ','e'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;str&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;position_of_the_word&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;extract_the_word&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;screen shots or pictures of errors with ture and ...&lt;/TD&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;TD class="l data"&gt;ture&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 09 Mar 2020 18:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630706#M186746</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T18:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630707#M186747</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data want;
 str="screen shots or pictures of errors with ture and ...";
 want=prxchange('s/.*(\bture\b).*/$1/i', -1, str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 18:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630707#M186747</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T18:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630717#M186753</link>
      <description>&lt;P&gt;Hi;&lt;BR /&gt;Thanks for prompt answer. How can I tailor those codes for variable name that contains the text instead of single string? The variable name is Text and again I'm looking for "ture".&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 19:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630717#M186753</guid>
      <dc:creator>Behrouz</dc:creator>
      <dc:date>2020-03-09T19:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630720#M186754</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135052"&gt;@Behrouz&lt;/a&gt;&amp;nbsp; The following example should help you follow&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Let's assume HAVE is your source dataset and STR is the variable name*/
data have;
 str="screen shots or pictures of errors with ture and ...";
run;
/*Read the source dataset HAVE and create the new variable*/
data want;
 set have;
 position_of_the_word=findw(str,'ture',' ','e');/*position of the word in the string*/
 extract_the_word=scan(str,findw(str,'ture',' ','e'));/*extract the word in the string*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 19:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630720#M186754</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T19:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630734#M186759</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As I mentioned, the variable (column) name is "Text". Where do you put the variable name (Text) in your codes? and the column has over 100 million records and "screen shots or pictures of errors with ture and ..." is just one single example out of 100 million observations. I just gave this example to show you what am I trying to do. Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630734#M186759</guid>
      <dc:creator>Behrouz</dc:creator>
      <dc:date>2020-03-09T20:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630738#M186760</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135052"&gt;@Behrouz&lt;/a&gt;&amp;nbsp; The HAVE is the sample dataset I created to test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WANT is the dataset that is our required output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Extract_the_word is the new variable that we create in the WANT dataset by reading the HAVE(your input)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The STR variable is the TEXT variable that has the string variables, so please replace the STR with whatever name your TEXT variable contains.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630738#M186760</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T20:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630739#M186761</link>
      <description>&lt;P&gt;Hello Mam/Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/14323"&gt;@ShelleySessoms&lt;/a&gt;&amp;nbsp;/&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;Something I clicked accidentally by mistake made my reply overwrite OP's prev message. I don't know how to undo. My sincere apologies for the bother. Kindly help.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630739#M186761</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T20:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630741#M186763</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;Restored. Careful with those Super User powers!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630741#M186763</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2020-03-09T20:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630742#M186764</link>
      <description>&lt;P&gt;Thank you Sir. I will be -first and last mistake. My apologies again!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630742#M186764</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T20:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630744#M186766</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135052"&gt;@Behrouz&lt;/a&gt;&amp;nbsp; &amp;nbsp;I get the feeling, you are confused with the know-how of how a datastep read/write process happens.&amp;nbsp; I have edited my previous code replacing str as text.. See if you can copy paste to your real stuff properly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Let's assume HAVE is your source dataset and STR is the variable name*/
data have;
 text="screen shots or pictures of errors with ture and ...";
run;
/*Read the source dataset HAVE and create the new variable*/
data want;
 set have;
 position_of_the_word=findw(text,'ture',' ','e');/*position of the word in the string*/
 extract_the_word=scan(str,findw(text,'ture',' ','e'));/*extract the word in the string*/
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630744#M186766</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T20:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630896#M186830</link>
      <description>&lt;P&gt;Hi;&lt;/P&gt;&lt;P&gt;I'm quite familiar with data steps. I guess my problem was with the first part of your codes:&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 text&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"screen shots or pictures of errors with ture and ..."&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you run it, you get a dataset with only one variable and one observation. So, I think this part wasn't needed. I also became confused with str as variable name. Actually, I thought it is a function. Anyway, I got what I wanted and I like to thank you with helping me out with this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 13:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630896#M186830</guid>
      <dc:creator>Behrouz</dc:creator>
      <dc:date>2020-03-10T13:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630899#M186832</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135052"&gt;@Behrouz&lt;/a&gt;&amp;nbsp; &amp;nbsp;We're all glad. Sorry, I ran into lot of confusion as I failed to explain comprehensively. More so than techniques/concepts I am learning communication skill on the forum.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, the HAVE part is basically to create a sample for us to test. The original poster (OP) of the question like you may or may not post a sample and the expected output clearly. This leads us to create one to test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay, going forward, here is an approach to frame a good question-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Post a sample of your input dataset (HAVE)&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;&amp;nbsp;Post a sample of your expected output dataset (WANT)&lt;/P&gt;
&lt;P&gt;3. Briefly explain the business/transformation logic in simple sentences and we are good to go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Makes sense? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 13:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630899#M186832</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-10T13:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630904#M186836</link>
      <description>&lt;P&gt;No worries. We are all learning everyday from each other. I've been using SAS for a long time, but I didn't even know there is a&amp;nbsp;findw function! I felt kind of naive...But, I guess that's the beauty of life, being surprised &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 13:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-word/m-p/630904#M186836</guid>
      <dc:creator>Behrouz</dc:creator>
      <dc:date>2020-03-10T13:24:42Z</dc:date>
    </item>
  </channel>
</rss>

