<?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: deleting a variable on the basis of another variable in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415028#M12668</link>
    <description>&lt;P&gt;You want to delete all obs for a firm if any record of that frim has var_a between 2 and 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this with a SET command that reads all var_a between 2 and 4 for a given firm prior to reading all records for the same firm:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Firm $1. var_A ;
datalines;
a  1           
a  2 
a  3
a  4
a  5
b  2
b  1
c  1
run;

data want (drop=exclude);
  set have (where=(var_a between 2 and 4)  in=found_2_to_4)
      have (in=allobs);
  by firm;
  if first.firm then exclude=ifn(found_2_to_4=1,1,0);
  retain exclude;
  if allobs=1 and exclude=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Nov 2017 05:09:13 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-11-21T05:09:13Z</dc:date>
    <item>
      <title>deleting a variable on the basis of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415025#M12666</link>
      <description>&lt;P&gt;Hello Folks,&lt;/P&gt;
&lt;P&gt;I have following kind of data;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Firm var_A&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;b&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;b&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;1&lt;/P&gt;
&lt;P&gt;c&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i know i can always use "if and then statement" but it will delete only 2,3 and 4.&lt;/P&gt;
&lt;P&gt;i&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;want to&amp;nbsp;Delete&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Firm,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if the var_A is between 2 to 4.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;i&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;don't want to delete the only 2-4 but what&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;i&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;want is to delete the all of the Firm if any on the Var_A comes in the range of 2-4. so after that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;logic&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;only C will remain. all of Firm A and b should delete.&amp;nbsp;&lt;BR /&gt;I will be thankful for any help.&amp;nbsp;&lt;BR /&gt;Regards&lt;/P&gt;
&lt;P&gt;raq&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 04:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415025#M12666</guid>
      <dc:creator>raqthesolid</dc:creator>
      <dc:date>2017-11-21T04:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: deleting a variable on the basis of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415027#M12667</link>
      <description>&lt;P&gt;There are probably several ways.&amp;nbsp; Here's one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;delete_flag = 0;&lt;/P&gt;
&lt;P&gt;do until (last.firm);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by firm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if var_a&amp;nbsp; in (2, 3, 4) then delete_flag=1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.firm);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by firm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if delete_flag = 0 then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop delete_flag;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 05:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415027#M12667</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-21T05:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: deleting a variable on the basis of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415028#M12668</link>
      <description>&lt;P&gt;You want to delete all obs for a firm if any record of that frim has var_a between 2 and 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this with a SET command that reads all var_a between 2 and 4 for a given firm prior to reading all records for the same firm:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Firm $1. var_A ;
datalines;
a  1           
a  2 
a  3
a  4
a  5
b  2
b  1
c  1
run;

data want (drop=exclude);
  set have (where=(var_a between 2 and 4)  in=found_2_to_4)
      have (in=allobs);
  by firm;
  if first.firm then exclude=ifn(found_2_to_4=1,1,0);
  retain exclude;
  if allobs=1 and exclude=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 05:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/deleting-a-variable-on-the-basis-of-another-variable/m-p/415028#M12668</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-11-21T05:09:13Z</dc:date>
    </item>
  </channel>
</rss>

