<?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: Delete negative values of multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688084#M208969</link>
    <description>&lt;P&gt;Here's a quick fix for missing values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Final_Data;
	DROP _:;
	SET	Acct_Data;
	ARRAY	Variables	[*] A -- C E -- P;

	DO	_i	=	1	to	DIM(Variables);
		if	NOT	MISSING(Variables[_i])	THEN
			if	Variables[_i] &amp;lt;	0		THEN
				DELETE;
	END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Thu, 01 Oct 2020 02:54:44 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-10-01T02:54:44Z</dc:date>
    <item>
      <title>Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688065#M208957</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have many accounting variables that are illogically negative. I want to delete all the negative values from all the variables except a few whose values can be negative. I can do that in the following ways:&lt;/P&gt;&lt;P&gt;if a&amp;lt;0 then delete;&lt;/P&gt;&lt;P&gt;if b&amp;lt;0 then delete;&lt;/P&gt;&lt;P&gt;so on. But this is not an efficient way to delete. Can anyone suggest me any efficient method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 01:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688065#M208957</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-10-01T01:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688067#M208958</link>
      <description>&lt;P&gt;If you code&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if a&amp;lt;0 then delete;
if b&amp;lt;0 then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you will delete the entire record -- all of the variables.&amp;nbsp; Is that what you want?&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to delete the entire record from the SAS dataset, then the DELETE command is reasonably efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I may not be understanding what you're trying to do.&amp;nbsp; Can you post 1) some sample data and 2) what your results should look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 01:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688067#M208958</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T01:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688069#M208959</link>
      <description>Yes, if any variable has a negative value, I want to delete the row.</description>
      <pubDate>Thu, 01 Oct 2020 01:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688069#M208959</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-10-01T01:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688072#M208962</link>
      <description>In my dataset, I have 15 variables in which there are some illogical negative values and there are 3 more variables in which negative values are logical. So, I want to delete all the rows that have negative values in the 15 variables. I can do that by writing 15 separate lines. But that is not efficient.</description>
      <pubDate>Thu, 01 Oct 2020 01:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688072#M208962</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-10-01T01:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688073#M208963</link>
      <description>&lt;P&gt;The way you are doing it is reasonably efficient.&amp;nbsp; You could make it a bit more efficient if you change&lt;/P&gt;
&lt;P&gt;FROM:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	FINAL_DATA;
	SET	ACCT_DATA;
	if a&amp;lt;0 then delete;
	if b&amp;lt;0 then delete;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TO:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	FINAL_DATA2;
	SET	ACCT_DATA;
	if a&amp;gt;0 AND b&amp;gt;0;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is it a very large dataset?&amp;nbsp; If it is not a large dataset, then you won't even notice any significant difference.&amp;nbsp; If you run with your DELETE's, how long is it taking to run?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also use a PROC SQL with a DELETE FROM - WHERE construct, but the rows will only be logically deleted.&amp;nbsp; The rows will not be physically deleted from the SAS dataset.&amp;nbsp; This would not be my preference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 01:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688073#M208963</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T01:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688074#M208964</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/260675"&gt;@abdulla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;In my dataset, I have 15 variables in which there are some illogical negative values and there are 3 more variables in which negative values are logical. So, I want to delete all the rows that have negative values in the 15 variables. I can do that by writing 15 separate lines. But that is not efficient.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Oh, oh, you mean in terms of coding.&amp;nbsp; "Efficient" usually means in terms of run time or CPU time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure.&amp;nbsp; Let me code something for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 01:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688074#M208964</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T01:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688077#M208965</link>
      <description>&lt;P&gt;OK, so let's say the variables that should not be negative are variables A through O (15 variables).&amp;nbsp; Let's make up some data:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1601518023925.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50030iD63ACD083A7830C7/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_0-1601518023925.png" alt="jimbarbour_0-1601518023925.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's some code that will delete any of the variables A through O if&amp;nbsp;&lt;EM&gt;any&lt;/EM&gt; one of the variables is negative:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Final_Data;
	SET	Acct_Data;
	ARRAY	Variables	[*] A -- O;

	DO	_i	=	1	to	DIM(Variables);
		if	Variables[_i] &amp;lt;	0	THEN
			DELETE;
	END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_1-1601518134712.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50031iDBEB5E7CEF73A06A/image-size/large?v=v2&amp;amp;px=999" role="button" title="jimbarbour_1-1601518134712.png" alt="jimbarbour_1-1601518134712.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;How's that look?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing to be aware of, the variables have to be all next to each other in order to use the A -- O notation.&amp;nbsp; If some of the variables that are allowed to be negative are in between A and O, you have to code the range a bit differently.&amp;nbsp; For example, if D is allowed to be negative, you would have to code A -- C and E -- P.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 02:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688077#M208965</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T02:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688080#M208967</link>
      <description>It seems like that it deletes the missing observations too. I don't want to delete missing observations or anything else.</description>
      <pubDate>Thu, 01 Oct 2020 02:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688080#M208967</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-10-01T02:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688081#M208968</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/260675"&gt;@abdulla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;In my dataset, I have 15 variables in which there are some illogical negative values and there are 3 more variables in which negative values are logical. So, I want to delete all the rows that have negative values in the 15 variables. I can do that by writing 15 separate lines. But that is not efficient.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Nope, it's not efficient. If you have negative values they will be the lowest value so check what your minimum is, if the minimum value across all 15 variables is less than 0 you delete the row.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/260675"&gt;@abdulla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;In my dataset, I have 15 variables in which there are some illogical negative values and there are 3 more variables in which negative values are logical. So, I want to delete all the rows that have negative values in the 15 variables. I can do that by writing 15 separate lines. But that is not efficient.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if min(of listofVars) &amp;lt; 0 then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list to replace "listofVars" above.&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 02:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688081#M208968</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-01T02:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688084#M208969</link>
      <description>&lt;P&gt;Here's a quick fix for missing values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	Final_Data;
	DROP _:;
	SET	Acct_Data;
	ARRAY	Variables	[*] A -- C E -- P;

	DO	_i	=	1	to	DIM(Variables);
		if	NOT	MISSING(Variables[_i])	THEN
			if	Variables[_i] &amp;lt;	0		THEN
				DELETE;
	END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 02:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688084#M208969</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T02:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688088#M208971</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nice suggestion.&amp;nbsp; I'll have to try that some time on a really big data set.&amp;nbsp; I would think the MIN function is going to have to check for missing and then compare each value successively to determine the minimum non-missing value and then determine if that minimum value is less than zero.&amp;nbsp; The array method has to check each for missing and then check each for less than zero -- but only until it finds a negative value.&amp;nbsp; I'm betting that there wouldn't be much difference in CPU time, but I could be wrong, particularly if negative values were for some reason weighted toward the end of the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 03:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688088#M208971</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T03:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688113#M208984</link>
      <description>Thanks Jim.</description>
      <pubDate>Thu, 01 Oct 2020 05:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688113#M208984</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-10-01T05:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688327#M209068</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, you are completely (&lt;EM&gt;completely&lt;/EM&gt;) on point here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran my array code and the MIN(of xxx) method you suggested with 500 million rows.&amp;nbsp; The&amp;nbsp;MIN(of xxx) method is considerably faster,&amp;nbsp;&lt;STRONG&gt;BUT&lt;/STRONG&gt;&amp;nbsp;there's some subtlety here.&amp;nbsp; Recall that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;'s article mentioned different methods of specifying the variables referenced by the "of".&amp;nbsp; While I was at it, I compared three types of references and my original array code:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Original array code&lt;/LI&gt;
&lt;LI&gt;IF MIN(of A -- C E -- P) &amp;lt; 0 then delete;&lt;/LI&gt;
&lt;LI&gt;ARRAY Variables [*] A -- C E -- P; IF MIN(of Variables[*]) &amp;lt; 0 then delete;&lt;/LI&gt;
&lt;LI&gt;IF MIN(of &amp;amp;Var_List) &amp;lt; 0 then delete;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;With 500 million rows, the results were (CPU time):&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;0:07:15.07&lt;/LI&gt;
&lt;LI&gt;0:05:18.89&lt;/LI&gt;
&lt;LI&gt;0:06:16.18&lt;/LI&gt;
&lt;LI&gt;0:05:24.98&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;My array code was about 2 CPU minutes&amp;nbsp;&lt;EM&gt;slower&lt;/EM&gt; than the fastest MIN(of xxx) code.&lt;/P&gt;
&lt;P&gt;As you might expect, examples 2 and 4 ran in about the same time.&amp;nbsp; They're both references by individual variable name and, when compiled, should be about the same.&lt;/P&gt;
&lt;P&gt;Surprisingly, (to me) the example using an array in the&amp;nbsp;MIN(of xxx) code, ran about a CPU minute slower than the non-array examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So some conclusions here:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Indexing through an array is considerably slower than a function with "of" and a variable list.&lt;/LI&gt;
&lt;LI&gt;The way the variable list is referenced matters.&amp;nbsp; Reference by array is significantly slower than by individual variable name.&lt;/LI&gt;
&lt;LI&gt;Arrays appear to have a material amount of overhead associated with them.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;This is all a bit esoteric, but still, these are good things to know.&amp;nbsp; I had always assumed that array overhead was minimal and that arrays were a fast way of doing most things.&amp;nbsp; Apparently this is not so, which is news to me.&amp;nbsp; I learned a little something here, so I thank you for your code suggestion,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, even though&amp;nbsp; I was not the original poster in this thread.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 19:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688327#M209068</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T19:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688329#M209070</link>
      <description>&lt;P&gt;Since I know you'll all be just dying to try this in your environment, here is my test script.&amp;nbsp; Seriously, though, if you come up with anything substantially different, I'd be curious to know about it.&amp;nbsp; I'm running on Windows Server 2016 x64 with SAS 9.4 M6 submitted via EG 8.2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Time_Stamp(START);

**------------------------------------------------------------------------------**;

%LET	Iterations	=	100000000;
*%LET	Iterations	=	5;
%LET	DSN			=	Acct_Data2;

**------------------------------------------------------------------------------**;

DATA	ACCT_DATA;
	INFILE	DATALINES DSD	DLM='|';
	INPUT	A
			B
			C
			D
			E
			F
			G
			H
			I
			J
			K
			L
			M
			N
			O
			P
			;
DATALINES;
1|-5|4|-7|18|15|241|78|18|15|241|78|18|15|241|5
18|15|241|-78|18|15|241|78|18|15|241|78|18|15|241|.
8|25|256|-718|18|15|241|78|18|15|241|78|18|15|241|3
76|4|-212|-32|18|15|241|78|18|15|241|78|18|15|241|22
7|4|212|-32|18|15|241|78|18|15|241|78|18|15|241|-2
;
RUN;

**------------------------------------------------------------------------------**;

PROC	CONTENTS	DATA=Acct_Data
					OUT=Acct_Data_Contents;
RUN;

**------------------------------------------------------------------------------**;

PROC	SQL	NOPRINT;
	SELECT	Name
			INTO	:	Var_List	SEPARATED BY ' '
		FROM	Acct_Data_Contents
			WHERE	Type	=	1
				AND	Name	^=	'D';
QUIT;

%PUT	&amp;amp;Nte1  &amp;amp;=Var_List;

**------------------------------------------------------------------------------**;

DATA	Acct_Data2;
	DROP	_:;
	SET	Acct_Data;
	DO _i	=	1	TO	&amp;amp;Iterations;
		OUTPUT;
	END;
RUN;

**------------------------------------------------------------------------------**;

DATA	Final_Data1;
	DROP _:;
	SET	&amp;amp;DSN;
	ARRAY	Variables [*] A -- C E -- P;

	DO	_i	=	1	to	DIM(Variables);
		if	NOT	MISSING(Variables[_i])	THEN
			if	Variables[_i] &amp;lt;	0		THEN
				DELETE;
	END;
RUN;

**------------------------------------------------------------------------------**;

DATA	Final_Data2;
	DROP _:;
	SET	&amp;amp;DSN;

	IF	MIN(of  A -- C E -- P) &amp;lt; 0 then delete;
RUN;

**------------------------------------------------------------------------------**;

DATA	Final_Data3;
	DROP _:;
	SET	&amp;amp;DSN;
	ARRAY	Variables [*] A -- C E -- P;  
	IF	MIN(of Variables[*]) &amp;lt; 0 then delete;
RUN;

**------------------------------------------------------------------------------**;

DATA	Final_Data4;
	DROP _:;
	SET	&amp;amp;DSN;

	IF	MIN(of &amp;amp;Var_List) &amp;lt; 0 then delete;
RUN;

**------------------------------------------------------------------------------**;

&amp;amp;Null	%MACRO	Delete_Work_Data;
	PROC	DELETE	DATA=Acct_Data;
	RUN;
	PROC	DELETE	DATA=Acct_Data2;
	RUN;

	%DO	i	=	1	%TO	4;
		PROC	DELETE	DATA=Final_Data&amp;amp;i;
		RUN;
	%END;
%MEND	Delete_Work_Data;

%Delete_Work_Data;

**------------------------------------------------------------------------------**;

%Time_Stamp(STOP);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Oct 2020 19:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688329#M209070</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T19:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688340#M209078</link>
      <description>Does resolving the macro variable add any overhead as well? I want to assume no but I'm not sure...otherwise your results are pretty much what I would have expected &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for doing the leg work on this, definitely an interesting read!</description>
      <pubDate>Thu, 01 Oct 2020 20:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688340#M209078</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-01T20:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688366#M209093</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Too close to call.&amp;nbsp; A few seconds difference between using name ranges vs. a macro variable.&amp;nbsp; That kind of difference could go either way each time the code is run, probably without any clear pattern (or at least that's my experience with run times this close together).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, since all the code is already written, let me run it a couple of times.&amp;nbsp; It takes less than 15 minutes per run.&amp;nbsp; I'll report back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 21:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688366#M209093</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T21:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Delete negative values of multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688402#M209115</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've run the tests several times now with 500 million rows each.&amp;nbsp; The CPU run time differences between the various form of variable reference in the MIN(of XXX) don't seem to matter much including the array reference.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one thing that stands out is that the all array method takes about 7.5&amp;nbsp; minutes but the&amp;nbsp;MIN(of XXX) methods take about 5.5 minutes each.&amp;nbsp; The&amp;nbsp;MIN(of XXX) method taking 5.5 minutes is pretty consistent no matter if the variable set is specified by range(s), a macro var, or by an array reference.&amp;nbsp; My first run showed some slowness in an array reference, but that appears to have been a one time thing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 23:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-negative-values-of-multiple-variables/m-p/688402#M209115</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-01T23:32:08Z</dc:date>
    </item>
  </channel>
</rss>

