<?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 can I better Delete Many Rows that meet many conditions in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552573#M74618</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271271"&gt;@gorba004&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, please note that your suggested WHERE condition is inconsistent with your requirement: You would need to replace "AND" with "OR" to correct this. (The "&amp;lt;&amp;gt;" works like "NE" &lt;EM&gt;in a WHERE condition&lt;/EM&gt;, but I still wouldn't use it for the reason&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;has explained.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As has been suggested, you can use functions with an &lt;FONT face="courier new,courier"&gt;OF &lt;EM&gt;variable-list&lt;/EM&gt;&lt;/FONT&gt; argument to simplify the condition, where&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;variable-list&lt;/EM&gt;&lt;/FONT&gt; may be a list of arbitrary variable names (it's not limited to numbered range lists etc.). If you need more than one function, you can use an array to avoid duplicating the long list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new_set;
array x[*] list your variables here;
set old_set;
if not(nmiss(of x[*])=sumabs(of x[*])=0);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 19 Apr 2019 23:42:29 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-04-19T23:42:29Z</dc:date>
    <item>
      <title>How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552524#M74607</link>
      <description>&lt;P&gt;I am working with a dataset that has 110,000 observations and 170 variables. I am trying to delete all the observations that are 0 in all of around 30 variables. They must be 0 in all of the 30 variables. This is what I have done so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA new_set;&lt;/P&gt;&lt;P&gt;SET old_set (WHERE= (var1&amp;lt;&amp;gt;0 AND var2&amp;lt;&amp;gt;0 AND var3&amp;lt;&amp;gt;0 AND var4&amp;lt;&amp;gt;0 AND....var30&amp;lt;&amp;gt;0));&lt;/P&gt;&lt;P&gt;RUN;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variables are not in actually numbered 1-30, are not all in a row, and are sparsely scattered about the other 170 in the dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easier or more efficient way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS 9.4 (Unicode)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 19:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552524#M74607</guid>
      <dc:creator>gorba004</dc:creator>
      <dc:date>2019-04-19T19:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552531#M74609</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1-var3;
cards;
0 0 0
0 1 0
0 1 2
;


data want;
set have;
k=compress(cats(of var1-var3),'0');
if missing(k) then delete;
drop k;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Apr 2019 19:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552531#M74609</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-19T19:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552550#M74610</link>
      <description>&lt;P&gt;The 30 variables appear to be numeric so this should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if sum(of var1-var30) = 0 then delete;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Apr 2019 22:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552550#M74610</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-04-19T22:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552556#M74611</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The 30 variables appear to be numeric so this should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if sum(of var1-var30) = 0 then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would hesitate to use that alone. Since the OP is attempting to use &amp;lt;&amp;gt; as not equal there may actually be negative values. So if there is a -1 and a +1 the sum would be 0 . Sum=0 and Range=0 might be sufficient though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271271"&gt;@gorba004&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not want to use &amp;lt;&amp;gt; if looking to do a "not equal", use one of: NE &amp;nbsp;^=&lt;/P&gt;
&lt;P&gt;Examine this code and the result:&lt;/P&gt;
&lt;PRE&gt;data example;
   x= 5;
   y1 = x &amp;lt;&amp;gt; 2;
   y2 = x &amp;lt;&amp;gt; 7;
   z =  x ne 2;
run;&lt;/PRE&gt;
&lt;P&gt;The &amp;lt;&amp;gt; returns the larger of the two values. The x ne 2 returns a 1 for true.&lt;/P&gt;
&lt;P&gt;And while SAS will treat any number not 0 or missing as "True" you may get very unexpected results from comparisons if you use &amp;lt;&amp;gt; instead of NE if you intend "not equal" for the comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552556#M74611</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-19T23:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552557#M74612</link>
      <description>&lt;P&gt;That's exactly what i was wondering&amp;nbsp;&amp;nbsp; even a champion like Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp; who taught me effective boolean expressions can get "&lt;STRONG&gt;jetlagged"&lt;/STRONG&gt; on way to dallas? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552557#M74612</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-19T23:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552559#M74613</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; - good point. If data is all greater than or equal to zero it should be OK.&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552559#M74613</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-04-19T23:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552560#M74614</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; - quite likely. I've got a 3 hour followed by a 15.5 hour flight to contend with....&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552560#M74614</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-04-19T23:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552565#M74615</link>
      <description>&lt;P&gt;Have a safe trip and great fun sir.&amp;nbsp; Pass on my regards to our coomunity folks in SGF. Cheers!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552565#M74615</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-19T23:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552570#M74617</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; - good point. If data is all greater than or equal to zero it should be OK.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Care to guess how&amp;nbsp;much time I spent diagnosing a very similar issue years ago where a very small number of records had that offsetting sum behavior? Though in the case I had it was a combination of 4 variables where one negative value just happened to match the total of 3 positive...&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552570#M74617</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-19T23:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552573#M74618</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271271"&gt;@gorba004&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, please note that your suggested WHERE condition is inconsistent with your requirement: You would need to replace "AND" with "OR" to correct this. (The "&amp;lt;&amp;gt;" works like "NE" &lt;EM&gt;in a WHERE condition&lt;/EM&gt;, but I still wouldn't use it for the reason&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;has explained.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As has been suggested, you can use functions with an &lt;FONT face="courier new,courier"&gt;OF &lt;EM&gt;variable-list&lt;/EM&gt;&lt;/FONT&gt; argument to simplify the condition, where&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;variable-list&lt;/EM&gt;&lt;/FONT&gt; may be a list of arbitrary variable names (it's not limited to numbered range lists etc.). If you need more than one function, you can use an array to avoid duplicating the long list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new_set;
array x[*] list your variables here;
set old_set;
if not(nmiss(of x[*])=sumabs(of x[*])=0);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552573#M74618</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-04-19T23:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552575#M74620</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;nmiss&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of x&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sumabs&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of x&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Super slick&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552575#M74620</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-19T23:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552583#M74621</link>
      <description>&lt;P&gt;Using array makes life easier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
      array varx var1-var30;
      do i=1 to dim(varx);
           if varx(i) &amp;lt;&amp;gt; 0 then do; output; leave; end;
      end;
      drop i ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Apr 2019 01:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552583#M74621</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-04-20T01:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552606#M74623</link>
      <description>&lt;P&gt;You want to delete a row of variables each having a value of zero. Don't you want to delete Columns having zeros?&lt;/P&gt;
&lt;P&gt;For instance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input var1-var3;
cards;
0 0 0
0 1 0
0 1 2
;
run;&lt;/PRE&gt;
&lt;P&gt;If you delete the first row, you will have the entire column (VAR1) with zeros. Do you want VAR1 to be kept?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2019 06:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552606#M74623</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-04-20T06:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552617#M74624</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1-var3;
cards;
0 0 0
0 1 0
0 1 2
;


data want;
set have;
array x{*} var1-var3;
if min(of x{*})=0 and max(of x{*})=0 then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Apr 2019 10:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552617#M74624</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-20T10:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I better Delete Many Rows that meet many conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552656#M74626</link>
      <description>&lt;P&gt;Thanks so much, this worked like a charm&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2019 20:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-better-Delete-Many-Rows-that-meet-many-conditions/m-p/552656#M74626</guid>
      <dc:creator>gorba004</dc:creator>
      <dc:date>2019-04-20T20:47:22Z</dc:date>
    </item>
  </channel>
</rss>

