<?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 to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367392#M87455</link>
    <description>&lt;P&gt;Thank you for the response. I believe this only deletes the negative retraction, but I would want to delete both the negative and positive paid with the same value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so both of the below lines should be deleted. &lt;/P&gt;
&lt;PRE&gt;1 1/25/15 apple 43
1 1/25/15 apple -43&lt;/PRE&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 14:42:30 GMT</pubDate>
    <dc:creator>johnjinkim</dc:creator>
    <dc:date>2017-06-15T14:42:30Z</dc:date>
    <item>
      <title>How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367381#M87447</link>
      <description>&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;input person date product paid ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;1 1/25/15 apple $43&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 1/25/15 apple -$43&lt;/P&gt;
&lt;P&gt;1 1/25/15 apple $50&lt;/P&gt;
&lt;P&gt;2 1/30/15 orange $50&lt;/P&gt;
&lt;P&gt;3 1/31/15 apple $55&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Would want to remove lines:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;1 1/25/15 apple $43&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 1/25/15 apple -$43&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;since it is the same person #, date, product, and price is retracted. Would want to keep person #1 apple $50 as well as persons 2 and 3. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Thank you! &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367381#M87447</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2017-06-15T14:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367386#M87451</link>
      <description>&lt;P&gt;Could you summarize by customer, date, product and sum the amount. If amount is 0 then delete?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367386#M87451</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-15T14:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367388#M87452</link>
      <description>&lt;P&gt;Here is one example:&lt;/P&gt;
&lt;PRE&gt;data have;
  input person date $ product $ paid;
datalines;
1 1/25/15 apple 43
1 1/25/15 apple -43
2 1/30/15 orange 50
3 1/31/15 apple 55
;
run;

data want;
  set have;
  by person date product;
  retain tot;
  if first.product then tot=paid;
  if not(first.product) and tot+paid=0 then delete;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367388#M87452</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-15T14:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367391#M87454</link>
      <description>&lt;P&gt;Good thought - have updated initial question as it does not appear for scenarios where there are other lines for that person that I would want to keep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Truly trying to remove only retractions with the same positive and negative value.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367391#M87454</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2017-06-15T14:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367392#M87455</link>
      <description>&lt;P&gt;Thank you for the response. I believe this only deletes the negative retraction, but I would want to delete both the negative and positive paid with the same value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so both of the below lines should be deleted. &lt;/P&gt;
&lt;PRE&gt;1 1/25/15 apple 43
1 1/25/15 apple -43&lt;/PRE&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367392#M87455</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2017-06-15T14:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367399#M87458</link>
      <description>&lt;P&gt;Use a SQL self join to the data on the condition that it not equal a negative value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select a.*&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from have as a&lt;/P&gt;
&lt;P&gt;left join have as b&lt;/P&gt;
&lt;P&gt;on a.id=b.Id and a.date=b.date and a.item =b.item&lt;/P&gt;
&lt;P&gt;and a.amount ne -1*b.amount;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367399#M87458</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-15T14:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367729#M87594</link>
      <description>&lt;P&gt;There are some problem in my code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input person date : $20. product $ paid : dollar.;
cards;
1 1/25/15 apple $43
1 1/25/15 apple $-43
1 1/25/15 apple $50
2 1/30/15 orange $50
3 1/31/15 apple $55
;
data a;
 set have(where=(paid gt 0));
run;
data b;
 set have(where=(paid lt 0));
 paid=-paid;
run;
proc sort data=a;
 by  person date product paid;
run;
proc sort data=b;
 by  person date product paid;
run;

data want;
 ina=0;inb=0;
 merge a(in=ina)  b(in=inb);
 by person date product paid;
 if not (ina and inb) then do;
  if inb then paid=-paid;
  output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Jun 2017 02:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367729#M87594</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-17T02:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367830#M87629</link>
      <description>&lt;P&gt;I won't be overly confident on order of events&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input person date : $20. product $ paid : dollar.;
cards;
1 1/25/15 apple $50
1 1/25/15 apple $43
1 1/25/15 apple $-43
2 1/30/15 orange $50
3 1/31/15 apple $55
;
data want;
 ina=0;inb=0;
 merge have(where=(paid lt 0) in=ina) have(where=(paid gt 0) in=inb);
 by person date product;
 if not (ina and inb);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367830#M87629</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2017-06-16T17:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367838#M87631</link>
      <description>&lt;P&gt;At first glance, this looks rather straightforward, however, after&amp;nbsp;discovering the question could&amp;nbsp; involve both sequencing and no-sequencing process, &amp;nbsp;It seems that&amp;nbsp;Hash object is to be utilized&amp;nbsp;to deliver a more robust solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input person date : $20. product $ paid : dollar.;
cards;
1 1/25/15 apple $50
1 1/25/15 apple $43
1 1/25/15 apple $-43
2 1/30/15 orange $50
3 1/31/15 apple $55
;

data want;
if _n_=1 then do;
  if 0 then set have;
    declare hash h(dataset:'have(rename=(paid=_p) where=(_p&amp;lt;0))', multidata:'y'); 
	h.definekey('person','date','product');
	h.definedata(all:'y');
	h.definedone();
	call missing (_p);
  end;
set have (where=(paid&amp;gt;=0));
_rc=h.find();
if paid eq -1*_p then do;
_rc=h.removedup();
delete;
end;

drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 18:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/367838#M87631</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2017-06-16T18:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/368252#M87801</link>
      <description>&lt;P&gt;Thank you! This gets me to exactly what I need - apologies if the smaller level detalis/intracicies were not clearly stated. Seems as though it is fairly straightforward initially, but there are certainly smaler level detalis that this accounts for such as the sequencing.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 11:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/368252#M87801</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2017-06-19T11:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Obs w/ Positive and Negative Values based on Same Values in Other Variables/Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/368254#M87802</link>
      <description>&lt;P&gt;Thanks for the response. This creates duplicates of certain values ... performing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have nodupkey ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id date item ;&lt;/P&gt;
&lt;P&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;does get me to the output I specified, though not accounting for smaller level detalis that Haikuo's solution accounts for. Thanks again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Obs-w-Positive-and-Negative-Values-based-on-Same/m-p/368254#M87802</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2017-06-19T12:00:17Z</dc:date>
    </item>
  </channel>
</rss>

