<?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 Replacing whole string IF that string contains a certain sub string. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403399#M278932</link>
    <description>&lt;P&gt;I have a string variable called degree that contains student's majors. My problem is that the majors were written in so they are not uniform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp; for history majors, some say "history" and some say "mod-hist". Some say "stat" while some say "statistics". Some are capitalized, some are not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to make all of the majors have a uniform label. I want all of the history majors to have "history" as their major. All of the stats majors to have "statistics" as their major. (etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the most simple way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to find somewhere to search for a substring such as "hist" and then replace that&amp;nbsp;WHOLE string value (not just the substring) with "history" but I haven't found a way to do that.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2017 00:27:27 GMT</pubDate>
    <dc:creator>UCFtigers2017</dc:creator>
    <dc:date>2017-10-12T00:27:27Z</dc:date>
    <item>
      <title>Replacing whole string IF that string contains a certain sub string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403399#M278932</link>
      <description>&lt;P&gt;I have a string variable called degree that contains student's majors. My problem is that the majors were written in so they are not uniform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp; for history majors, some say "history" and some say "mod-hist". Some say "stat" while some say "statistics". Some are capitalized, some are not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to make all of the majors have a uniform label. I want all of the history majors to have "history" as their major. All of the stats majors to have "statistics" as their major. (etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the most simple way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to find somewhere to search for a substring such as "hist" and then replace that&amp;nbsp;WHOLE string value (not just the substring) with "history" but I haven't found a way to do that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 00:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403399#M278932</guid>
      <dc:creator>UCFtigers2017</dc:creator>
      <dc:date>2017-10-12T00:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing whole string IF that string contains a certain sub string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403411#M278933</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
if find(DEGREE, 'hist', 'i') then DEGREE='History';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 01:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403411#M278933</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-10-12T01:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing whole string IF that string contains a certain sub string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403429#M278934</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would start by making everything Proper or Upper Case.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then remove all the obvious values that are already ok.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then make your rules and recode things. It may mean a lot of IF/THEN statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the character functions in the documentation (search SAS functions by category) to see useful functions such as COMPRESS, COMBL, FIND and INDEX.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 03:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403429#M278934</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-12T03:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing whole string IF that string contains a certain sub string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403473#M278935</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170667"&gt;@UCFtigers2017&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I would be doing something similar to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;suggests:&lt;/P&gt;
&lt;P&gt;1. compbl() and propcase() your source variable&lt;/P&gt;
&lt;P&gt;2. create a table with distinct values&lt;/P&gt;
&lt;P&gt;3. use these values to create a format (i.e. export the table to Excel, add your standardized labels, re-import the Excel and create a format out of it)&lt;/P&gt;
&lt;P&gt;4. apply the format to the original values (with compl() and propcase() applied first) to standardize the strings.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 09:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403473#M278935</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-12T09:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing whole string IF that string contains a certain sub string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403595#M278936</link>
      <description>&lt;P&gt;You may have to &lt;STRONG&gt;very carefully&lt;/STRONG&gt; consider the order of your processing and the actual desired target(s).&lt;/P&gt;
&lt;P&gt;ExampleS: Art History,Secondary Education- History emphasis&lt;/P&gt;
&lt;P&gt;Is&amp;nbsp;Art History&amp;nbsp;an Art degree or History or possibly Humanities? If it is Art then you would have to search and replace 'Art' before your "hist" search AND the replacement value could not contain the word History. Otherwise your other search would change it from Art to History.&lt;/P&gt;
&lt;P&gt;And perhaps you have some majors that don't actually include the 'key' value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is Business Statistics a Business degree or a Statistics degree (or program or major or concentration or ??).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might take a different approach then "if / then /else" by creating a&amp;nbsp;list of all of the unique&amp;nbsp;values and creating a format or even an Informat, to allow use of Just and Upcase options for comparison,&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-whole-string-IF-that-string-contains-a-certain-sub/m-p/403595#M278936</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-12T15:25:33Z</dc:date>
    </item>
  </channel>
</rss>

