Date: Wed, 8 Sep 1999 16:57:15 -0500
Reply-To: "Tverdek, Edward" <etverdek@SPSS.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Tverdek, Edward" <etverdek@SPSS.COM>
Subject: Re: NMISS Command
If Michael wishes to return the sum of variables a and b when
c is missing, as well as every other possible parsing of
variables along these lines, this is indeed what the SUM function
would do. It simply sums valid values across a list of arguments,
ignoring those that are missing (see the Syntax Reference Guide
for details on the SUM.n operator which allows you to specify the
minimum number of valid values necessary to return a valid sum;
1 is the default for n).
If, on the other hand, Michael has a "listwise" operation in mind,
wherein SPSS would return a system-missing value for the sum if
any of the variables being added are missing, he can simply use
the additive operator, as in
In either case, the need for the elaborate DO IF...ELSE IF structure
would be obviated.
SPSS Technical Support
From: Hector E. Maletta [mailto:firstname.lastname@example.org]
Sent: Wednesday, September 08, 1999 4:28 PM
To: Tverdek, Edward
Cc: SPSSX-L@LISTSERV.UGA.EDU; 'Michael Mallen'; email@example.com
Subject: Re: NMISS Command
It is interesting to know that NMISS counts also user-missing values,
contrary to what the Ref.Manual states.
Regarding the alternative syntax using the SUM function, as Edward
suggests towards the end of his message, I wonder whether this is
exactly what M;ichael wants. If a list of three arguments a, b and c is
provided, would SUM produce the sum of a+b when c is missing? Or it has
a "listwise" implicit rule that fails to return anything when any
argument is missing? I think the latter is what Michael wants. Further
clarification by Edward would be welcome.
Universidad del Salvador
Buenos Aires, Argentina
"Tverdek, Edward" wrote:
> Actually, NMISS does count user-defined missing values along
> with system-missing values, as this little job illustrates
> when you run it:
> DATA LIST /x1 TO x5 1-5.
> BEGIN DATA
> END DATA.
> MISSING VALUES x2 (2).
> COMPUTE y=NMISS(x1 TO x5).
> Some of the confusion is attributable to the SPSS Base 9.0 Syntax
> Reference Guide (and probably its predecessors) which does indeed
> describe NMISS as returning only the "Number of system-missing values
> in the argument list." I'll look into getting this clarified in the
> In Michael's case, something appears to be off in the specification
> of the user-defined missing values. He'll want to make sure that
> missing values which he's specifying as, say, 7.00 are actually stored
> as 7.00 and not something slightly different due to approximation in the
> binary representation of the values in SPSS (especially if the variable
> in question is the result of a data transformation). In addition, if
> variable names are similar, it's possible that variables other than those
> intended have been assigned missing values. Running DISPLAY DICTIONARY
> will provide a listing of the dictionary information for each variable,
> including missing values assigned to it.
> More importantly, if the purposes of the elaborate DO IF...ELSE IF
> structure is to sum the balance of variables conditionally when
> one of them is missing, and to evaluate each variable iteratively
> for this purpose, Michael can avoid all of this by simply replacing the
> additive "+" operator with the SUM function, reducing the whole task to
> COMPUTE x=SUM(a,b,c).
> SUM returns the sum of valid values across the arguments, hence there's
> no need to accommodate for the possibility that some arguments might
> be missing.
> Hope this helps,
> Ed Tverdek
> Training Coordinator
> SPSS Technical Support
> -----Original Message-----
> From: Hector E. Maletta [mailto:firstname.lastname@example.org]
> Sent: Wednesday, September 08, 1999 2:48 PM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: Re: NMISS Command
> the NMISS function in your DO IF condition refers only to SYSTEM missing
> values. It yields the number of system missing values in the argument
> list. Since your values are legitimate numbers (though declared as user
> missing) they are not system missing and thus NMISS yields a zero.
> Therefore SPSS proceeds with the calculation. You said nothing about
> user missing values.
> To do what you intend, I think the correct function is not NMISS but
> NVALID, which operates in a similar mode but yields the number of valid
> values. Your condition now should be: DO IF NVALID (A, B, C)=3.
> By the way, NMISS is not a command: it is a function that can be used in
> the computation of new variables just as SUM, MEAN, LOG or the rest of
> available functions. It is accepted by the COMPUTE, IF and DO IF
> commands (perhaps also by other commands, I do not recall more at the
> moment but memory is frail).
> Hector Maletta
> Universidad del Salvador
> Buenos Aires, Argentina
> Michael Mallen wrote:
> > I looked at my syntax again and still confused. You
> > are right, the variables are specified as user missing (7,8,9) and then
> > write a loop:
> > e.g.
> > do if nmiss (a,b,c) = 0.
> > compute x = (a + b + c).
> > else if nmiss (a) = 1.
> > compute x = (b + c)
> > etc.
> > I checked it with hand and SPSS did use user missing specifications in
> > computation of some of these variables. So, say the value for a = 7 and
> > specified as user missing, x was 7+b+c and not b+c. Thanks again.