<?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: How do I delete observations with IF/THEN during Merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419743#M103228</link>
    <description>&lt;P&gt;Thanks Art.&amp;nbsp; Yes, I incorrectly stated my intentions.&amp;nbsp; I want to delete marketers within companies. E.g. each company has multiple marketer codes.&amp;nbsp; Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs | Company&amp;nbsp; |&amp;nbsp; Marketer&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 001&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 002&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 003&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marketer codes 002 and 004 are inactive so I want to delete observations 2 and 4&amp;nbsp; when merging in that data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2017 23:50:27 GMT</pubDate>
    <dc:creator>awmeyertimmy</dc:creator>
    <dc:date>2017-12-08T23:50:27Z</dc:date>
    <item>
      <title>How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419734#M103219</link>
      <description>&lt;P&gt;I have two data sets.&amp;nbsp; Data set A contains all of my data.&amp;nbsp; Data set B includes company codes that I want to delete from data set A.&amp;nbsp; What I want to do is, If company code exists in data set B then delete all observations in data set A that have the same company code.&amp;nbsp; Here is what I have so far, but I know my if statement within the merge is incorrect. I'm using SAS 9.4&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Sort Data=Junk.Internet2;
by CompanyCode MarketerCode;
run;
Proc Sort Data=Junk.Inactivemktr;
by CompanyCode MarketerCode;
run;
DATA Junk.Internet2;
		Merge Junk.Internet2 (in=a)
				Junk.Inactivemktr (in=b);
				By CompanyCode MarketerCode;
		if a and not b;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can anyone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419734#M103219</guid>
      <dc:creator>awmeyertimmy</dc:creator>
      <dc:date>2017-12-08T23:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419736#M103221</link>
      <description>&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;	&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; not(a and  b)&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419736#M103221</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-08T23:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419737#M103222</link>
      <description>&lt;P&gt;Unfortunately that did not work. I'm still getting observations in my data set that should be excluded (deleted) in the data step&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419737#M103222</guid>
      <dc:creator>awmeyertimmy</dc:creator>
      <dc:date>2017-12-08T23:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419738#M103223</link>
      <description>&lt;P&gt;can you give a sample of your input and wanted output data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i think your approach is right. I don't know why you are merging by two by variables when the check is company code only.&amp;nbsp; Obviously, i don;t know your daata, so it's difficult to tell but merging by just company code with &lt;STRONG&gt;if a and not b&lt;/STRONG&gt; should work i think&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419738#M103223</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-08T23:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419739#M103224</link>
      <description>&lt;P&gt;If Marketercode variable has no role in the deletion then do not include it in the BY statement. If it does then explicitly describe the role it has.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have actually run this code it is likely that you have to rebuild your junk.internet2 set from scratch as you have used it as both a source and result in the same data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have multiple values of company code in both Internet2 and Inactivemktr then a data step merge may not be tool you need as it can have problems with many-to-many matches. If the&amp;nbsp;company code only appears once in the Inactivemktr then this might work (AFTER rebuilding Internet2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA Junk.Internet3;
   Merge Junk.Internet2 (in=a)
   	 Junk.Inactivemktr (in=b);
   By CompanyCode ;
   if b then delete;
RUN;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419739#M103224</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-08T23:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419740#M103225</link>
      <description>&lt;P&gt;Your code looks correct if you are trying to delete marketers within companies. But that isn't what you said you wanted to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to delete all companies if one of its marketers is in the inactivemktr file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, regardless of your response, your code currently wrecks the junk.internet2 file, thus if your code is wrong that file will be corrupted. I strongly suggest creating a new file, rather than replacing the existing file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419740#M103225</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-08T23:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419741#M103226</link>
      <description>&lt;P&gt;You're merging by&amp;nbsp;&lt;CODE class="  language-sas"&gt;CompanyCode and MarketerCode.&amp;nbsp;Therefore if you have CompanyCode "A" and MarketerCode "A" in dataset1 and CompanyCode "A" and MarketerCode "B" in dataset2, the resulting dataset will still have CompanyCode "A" and MarketerCode "A" since MarketerCode was not "B". Make sense? Can you merge by CompanyCode only? That's the easiest way to get it to work. You could probably do it in PROC SQL otherwise.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419741#M103226</guid>
      <dc:creator>bstarr</dc:creator>
      <dc:date>2017-12-08T23:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419743#M103228</link>
      <description>&lt;P&gt;Thanks Art.&amp;nbsp; Yes, I incorrectly stated my intentions.&amp;nbsp; I want to delete marketers within companies. E.g. each company has multiple marketer codes.&amp;nbsp; Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs | Company&amp;nbsp; |&amp;nbsp; Marketer&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 001&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 002&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 003&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; |A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marketer codes 002 and 004 are inactive so I want to delete observations 2 and 4&amp;nbsp; when merging in that data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419743#M103228</guid>
      <dc:creator>awmeyertimmy</dc:creator>
      <dc:date>2017-12-08T23:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419744#M103229</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Junk.Internet3;
		Merge Junk.Internet2 (in=a)
				Junk.Inactivemktr (in=b);
				By CompanyCode;
		if b then delete;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 23:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419744#M103229</guid>
      <dc:creator>awmeyertimmy</dc:creator>
      <dc:date>2017-12-08T23:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419745#M103230</link>
      <description>&lt;P&gt;No! I think your original code would do what you're trying to do .. as long as both company and marketercode are in both files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2017 00:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419745#M103230</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-09T00:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I delete observations with IF/THEN during Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419786#M103254</link>
      <description>&lt;P&gt;You need to supply example data for both datasets with observations where your code does not work as intended. Do so in data steps with datalines, so that it is easy for your possible helpers to recreate the datasets.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2017 09:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-delete-observations-with-IF-THEN-during-Merge/m-p/419786#M103254</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-09T09:10:05Z</dc:date>
    </item>
  </channel>
</rss>

