Date: Fri, 3 Mar 2000 17:47:25 -0800
Reply-To: Andrew James Llwellyn Cary <ajlcary@CARYCONSULTING.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Andrew James Llwellyn Cary <ajlcary@CARYCONSULTING.COM>
Subject: Re: deleting records where all numeric variables = 0
One Solution uses a trick in SAS: a logical operator can be mixed with
arithmetic operators to build a count of non-zero values.
ARRAY _NumVars_  _NUMERIC_ ;
DO __i =1 to DIM(_NumVars);
NNonZero = NNonZero + (_NumVars[__i] ~= 0 );
IF NNonZero = 0 THEN DELETE;
DROP __i NNonZero;
This method treats missing values as non-zero.
Another way uses the max and min functions...
IF MAX(OF -NUMERIC-) = 0 AND MIN(OF _NUMERIC_) = 0 THEN DELETE;
This method ignores missing values (effectively treating them as zero).
Caveat: none of this code was tested- there may be typos...
Andrew James Llwellyn Cary
Cary Consulting Services
"Nick Treadgold" <Nick_Treadgold@STATS.GOVT.NZ> wrote in message
> I would like to condense a dataset by deleting all records where all
> numeric variables = 0.
> this is one option....
> if var1=0 and var2=0 and var3=0 then delete ;
> but i'm sure there is a simpler and more obvious solution.
> this is not a suitable option for me....
> if sum(of var1-var3)=0 then delete;
> Nick Treadgold
> Economic Statistician
> Statistics New Zealand
> Phone: (03) 374 8834
> Fax: 03 374-8899
> Email: firstname.lastname@example.org
> Home Page: http://www.stats.govt.nz
> The information in this email, and any files transmitted with it, is
> confidential and is for the intended recipient only. If you receive this
> message in error, please phone us (collect) on 04-495-4600, or notify us
> via email@example.com