<?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 Complex Find and Replace using SAS? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522550#M32708</link>
    <description>&lt;P&gt;So I came across an issue with some data and I need to figure out a way for SAS to scan the dataset and replace with certain criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset is roughly 1mil rows so that adds to my complexity with trying to work this out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what I am looking for is that everytime the row meets the following criteria:&lt;/P&gt;
&lt;P&gt;Name in ('Matt') Segment in ('Tall') Number in ('20') Color in ('Blue')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need it to replace with:&lt;/P&gt;
&lt;P&gt;Name in ('John') Segment in ('Short') Number in ('40') Color in ('Green')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am just not sure how to do this replacing data with very specific row criteria like this.&amp;nbsp; I was thinking about a If/then statement in proc sql, but again I am not 100% sure of the syntax needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for anyone who can help.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 15:07:31 GMT</pubDate>
    <dc:creator>IgawaKei29</dc:creator>
    <dc:date>2018-12-19T15:07:31Z</dc:date>
    <item>
      <title>Complex Find and Replace using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522550#M32708</link>
      <description>&lt;P&gt;So I came across an issue with some data and I need to figure out a way for SAS to scan the dataset and replace with certain criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset is roughly 1mil rows so that adds to my complexity with trying to work this out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what I am looking for is that everytime the row meets the following criteria:&lt;/P&gt;
&lt;P&gt;Name in ('Matt') Segment in ('Tall') Number in ('20') Color in ('Blue')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need it to replace with:&lt;/P&gt;
&lt;P&gt;Name in ('John') Segment in ('Short') Number in ('40') Color in ('Green')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am just not sure how to do this replacing data with very specific row criteria like this.&amp;nbsp; I was thinking about a If/then statement in proc sql, but again I am not 100% sure of the syntax needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for anyone who can help.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522550#M32708</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2018-12-19T15:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Find and Replace using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522563#M32709</link>
      <description>&lt;P&gt;I think a data step would be easier than the equivalent SQL if I understand the entire issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   if Name in ('Matt')  and Segment in ('Tall') and Number in ('20') and Color in ('Blue') then do;
      Name    ='John';
      Segment ='Short';
      Number  ='40';
      Color   ='Green';   
   end;
run;&lt;/PRE&gt;
&lt;P&gt;Since SQL does not support IF/Then quite you would be using a CASE statement and would need a separate case statement for each variable to change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course one question is your "number" variable actually character valued as implied by your quotes around the variable? If number is actually numeric you would not use quotes at all for that variable.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522563#M32709</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-19T15:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Find and Replace using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522566#M32710</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I am not sure about the performance, but you can try to do it with regular expressions:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002601591.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002601591.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522566#M32710</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2018-12-19T15:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Find and Replace using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522585#M32711</link>
      <description>This was great, thank you.  I have filed this away into the code book!</description>
      <pubDate>Wed, 19 Dec 2018 15:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522585#M32711</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2018-12-19T15:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Find and Replace using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522587#M32712</link>
      <description>Yeah performance might be an issue, but I am going to try this out as well.  Never hurts to try a few different ways</description>
      <pubDate>Wed, 19 Dec 2018 15:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522587#M32712</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2018-12-19T15:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Find and Replace using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522589#M32713</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15187"&gt;@IgawaKei29&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset is roughly 1mil rows so that adds to my complexity with trying to work this out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don't use the original dataset for testing. Just create a temporary dataset consisting of a few representative observations from it and develop the code using this small dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to add to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s suggestion: If your replacement strings are longer than the original ones (as is the case in two of your examples), you need to make sure that the lengths of the respective character variables are sufficient to accommodate the longer values. If they are not, redefine the lengths as shown in the example below to avoid truncation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
color='Blue';
run;

data want;
length color $5; /* important: LENGTH statement before SET statement */
set have;
if color='Blue' then color='Green';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Complex-Find-and-Replace-using-SAS/m-p/522589#M32713</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-12-19T15:43:09Z</dc:date>
    </item>
  </channel>
</rss>

