<?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: Conditionally processing non-matching values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61865#M13468</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Can anybody tell me how I would do something similar in PROC SQL? I have another case involving a very large dataset and I run out of memory when sorting it. &lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
    <pubDate>Wed, 11 Aug 2010 13:41:39 GMT</pubDate>
    <dc:creator>Helle</dc:creator>
    <dc:date>2010-08-11T13:41:39Z</dc:date>
    <item>
      <title>Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61859#M13462</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset (A) containing usernames and email addresses of a number of people who entered data into a table in the past. Some of these people have left the company in the meantime. I want to check these usernames against a dataset of usernames of all current employees (B). If a username does not exist in B, the email address of that user in A must be changed into "xx@xx.com" (the same address for all ex-employees). &lt;BR /&gt;
&lt;BR /&gt;
I am sure there must be a simple way to do this but for some reason, I cannot get my head around it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help,&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
      <pubDate>Mon, 09 Aug 2010 11:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61859#M13462</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-08-09T11:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61860#M13463</link>
      <description>You could try something like this:&lt;BR /&gt;
&lt;BR /&gt;
data new;&lt;BR /&gt;
  merge A (in = a) B (in = b);&lt;BR /&gt;
  by user_name;&lt;BR /&gt;
  if a and not b then email = "xx@xx.com";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
This assumes tables A and B are already sorted in user_name order and in at least one of the tables user_name is unique. If this is not the case then using SQL may be preferable.</description>
      <pubDate>Mon, 09 Aug 2010 22:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61860#M13463</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2010-08-09T22:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61861#M13464</link>
      <description>The merge that SASKiwi suggests is one of several types of table look-ups.  Read more about other look-up methods at &lt;A href="http://caloxy.com/papers/43-i_how_table_lookups_from_ift.pdf" target="_blank"&gt;http://caloxy.com/papers/43-i_how_table_lookups_from_ift.pdf&lt;/A&gt; .</description>
      <pubDate>Mon, 09 Aug 2010 22:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61861#M13464</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-08-09T22:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61862#M13465</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot to both of you for your help. I wanted to end up with a dataset containing only the observations from A so I wrote the data step as follows:&lt;BR /&gt;
&lt;BR /&gt;
data new;&lt;BR /&gt;
merge A (in = a) B (in = b);&lt;BR /&gt;
by user_name;&lt;BR /&gt;
if a and not b then email = "xx@xx.com";&lt;BR /&gt;
if b and not a then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
      <pubDate>Tue, 10 Aug 2010 08:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61862#M13465</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-08-10T08:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61863#M13466</link>
      <description>The observation is either in A or B, so the simplest, most efficient code construct (given your output requirement) would be:&lt;BR /&gt;
&lt;BR /&gt;
if a and not b then email = "xx@xx.com";&lt;BR /&gt;
else delete;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 10 Aug 2010 08:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61863#M13466</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-08-10T08:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61864#M13467</link>
      <description>Hi Scott,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your suggestion. However, I want to keep all the observations from A and if I use your code, the only observations left in "new" are the ones that are not in B (all the ones which are in both A and B are deleted).&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
      <pubDate>Wed, 11 Aug 2010 13:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61864#M13467</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-08-11T13:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61865#M13468</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Can anybody tell me how I would do something similar in PROC SQL? I have another case involving a very large dataset and I run out of memory when sorting it. &lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
      <pubDate>Wed, 11 Aug 2010 13:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61865#M13468</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-08-11T13:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61866#M13469</link>
      <description>sql will still sort, unless it could perform a "hash join"&lt;BR /&gt;
Similar technology is available in a data step.&lt;BR /&gt;
Scalability of joins depends on memory available and data sizes. When you have that information, you can make an informed choice.&lt;BR /&gt;
The "seminal" (?) paper on sql joins, written some time ago but (imho) permanently relevant is at &lt;A href="http://support.sas.com/techsup/technote/ts553.html" target="_blank"&gt;http://support.sas.com/techsup/technote/ts553.html&lt;/A&gt; titled "SQL Joins -- The Long and The Short of It"&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Wed, 11 Aug 2010 15:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61866#M13469</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-08-11T15:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61867#M13470</link>
      <description>If you have a very large dataset and do not want to sort it there are at least two good choices:&lt;BR /&gt;
&lt;BR /&gt;
1) Hash join table B to table A in a DATA step, as mentioned by Peter.&lt;BR /&gt;
&lt;BR /&gt;
2) Create a SAS format from the username in table B using PROC FORMAT, then use the PUT function in a DATA step to do the lookup.&lt;BR /&gt;
&lt;BR /&gt;
Both of these techniques provide similar (very quick) performance as the lookups are done in memory. They are well-documented in online help so I would suggest doing some research yourself if you would like to check this out further.</description>
      <pubDate>Wed, 11 Aug 2010 22:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61867#M13470</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2010-08-11T22:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally processing non-matching values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61868#M13471</link>
      <description>Thanks for all your help - I will look into the different suggestions.&lt;BR /&gt;
&lt;BR /&gt;
Helle</description>
      <pubDate>Fri, 13 Aug 2010 13:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-processing-non-matching-values/m-p/61868#M13471</guid>
      <dc:creator>Helle</dc:creator>
      <dc:date>2010-08-13T13:37:42Z</dc:date>
    </item>
  </channel>
</rss>

