<?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: Locate a specific word in a data step, and assign a new value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64056#M18193</link>
    <description>Explore using the TRANWRD function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Recommended Google advanced search, this topic/post:&lt;BR /&gt;
&lt;BR /&gt;
character functions translate tranwrd site:sas.com</description>
    <pubDate>Wed, 03 Mar 2010 13:33:32 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2010-03-03T13:33:32Z</dc:date>
    <item>
      <title>Locate a specific word in a data step, and assign a new value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64055#M18192</link>
      <description>Hi!&lt;BR /&gt;
&lt;BR /&gt;
We ran into some problem here and I really could use some help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I am trying to locate a specific word (litium) from a variable which is coded as a string, with several different other values beside from litium. If a cell contains the word "litium", i want to assign the cell a new value such as "1", and if it doesn't contain the word "litium" I want it to be assigned "0".&lt;BR /&gt;
The "word" litium can be stored randomly in the cell, with other words around it, or after it etc.&lt;BR /&gt;
If it's possible I would like to do it as beutiful as possible, in a SAS data step &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Thank you!&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Christian and Maja.</description>
      <pubDate>Wed, 03 Mar 2010 13:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64055#M18192</guid>
      <dc:creator>ChrilleB</dc:creator>
      <dc:date>2010-03-03T13:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Locate a specific word in a data step, and assign a new value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64056#M18193</link>
      <description>Explore using the TRANWRD function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Recommended Google advanced search, this topic/post:&lt;BR /&gt;
&lt;BR /&gt;
character functions translate tranwrd site:sas.com</description>
      <pubDate>Wed, 03 Mar 2010 13:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64056#M18193</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-03T13:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Locate a specific word in a data step, and assign a new value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64057#M18194</link>
      <description>I would suggest &lt;BR /&gt;
newvar =  (index( word, 'litium') ne 0);</description>
      <pubDate>Wed, 03 Mar 2010 14:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64057#M18194</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-03-03T14:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Locate a specific word in a data step, and assign a new value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64058#M18195</link>
      <description>Thank you very much for your help!&lt;BR /&gt;
The tip from Flip worked out in a very good and easy way!&lt;BR /&gt;
&lt;BR /&gt;
Have a nice day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 03 Mar 2010 15:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64058#M18195</guid>
      <dc:creator>ChrilleB</dc:creator>
      <dc:date>2010-03-03T15:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Locate a specific word in a data step, and assign a new value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64059#M18196</link>
      <description>hi ... fyi, this might not apply with your current data set but ...&lt;BR /&gt;
&lt;BR /&gt;
sometimes there's a difference between looking for a WORD and &lt;BR /&gt;
looking for a STRING of characters&lt;BR /&gt;
&lt;BR /&gt;
when looking for a word, it's safer to use INDEXW &lt;BR /&gt;
since the search string might be embedded in the&lt;BR /&gt;
text of another word&lt;BR /&gt;
&lt;BR /&gt;
also, case might be an issue, so ...&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
input text $20.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Mary is from Maryland&lt;BR /&gt;
Scott is from Maryland&lt;BR /&gt;
mary is from Maryland&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data mary;&lt;BR /&gt;
set test;&lt;BR /&gt;
mary1 = index (text,'mary') ne 0;&lt;BR /&gt;
mary2 = indexw(text,'mary') ne 0;&lt;BR /&gt;
mary3 = index(upcase(text),'MARY') ne 0;&lt;BR /&gt;
mary4 = indexw(upcase(text),'MARY') ne 0;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Obs             text             mary1    mary2    mary3    mary4&lt;BR /&gt;
 1     Mary is from Maryland       0        0        1        1&lt;BR /&gt;
 2     Scott is from Maryland      0        0        1        0&lt;BR /&gt;
 3     mary is from Maryland       1        1        1        1&lt;BR /&gt;
[/pre]&lt;BR /&gt;
if I'm looking for any observation with the person Mary&lt;BR /&gt;
(regardless of case), only the variable MARY4 works with&lt;BR /&gt;
this data set</description>
      <pubDate>Wed, 03 Mar 2010 17:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Locate-a-specific-word-in-a-data-step-and-assign-a-new-value/m-p/64059#M18196</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2010-03-03T17:11:22Z</dc:date>
    </item>
  </channel>
</rss>

