Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANY Command in SPSS

4,873 views
Skip to first unread message

Hari

unread,
Dec 13, 2005, 3:05:45 AM12/13/05
to
Hi,

I see that here are 2 variations of ANY command. Let's suppose I have 3
variables in data file and q, w and e (in that order in data file)

a) One variation is I can check whether the variables q, w and e have a
particular value 2.
So I will write

if (any(2, q to e)) Flag1 = 23.
exe.

All cases which have a 2 in atleast one of the variables q to e would
have a value in flag1variable as 23.

Also if am interested in checking for variables q and e only (they are
not together in data file I may use

if (any(2, q, e)) Flag1 = 23.
exe.

b) Second variation is I can check whether a particular variable (let's
say w) has value 2 or 4 or 5 etc.. he syntax for this would be

if (any( w, 2,4, 5) flag2 = 67.

All cases which have variable w as equal to either 2 or 4 or 5 will
have the newly created flag2 variable equal to 67.

Suppose if I wanted to check for all values from 2 through 5 then if I
write

if (any( w, 2 thru 5) flag2 = 67.

yields an error, while writing it as

if (any( w, 2,3,4, 5) flag2 = 67. works without any problem (I know i
could have used if(range(w, 2, 5)) flag2 = 67. )

I would like to know as to why does SPSS allows usage of "to" in part
a) for specifying range of contiguous variables while in b) it doesnt
allow usage of "thru" for specufying contiguous values.

Regards,
Hari
India

Richard Ulrich

unread,
Dec 13, 2005, 2:08:26 PM12/13/05
to
On 13 Dec 2005 00:05:45 -0800, "Hari" <excel...@yahoo.com> wrote:

> Hi,
>
> I see that here are 2 variations of ANY command. Let's suppose I have 3
> variables in data file and q, w and e (in that order in data file)
>

[snip, first variation]


>
> b) Second variation is I can check whether a particular variable (let's
> say w) has value 2 or 4 or 5 etc.. he syntax for this would be
>
> if (any( w, 2,4, 5) flag2 = 67.
>
> All cases which have variable w as equal to either 2 or 4 or 5 will
> have the newly created flag2 variable equal to 67.
>
> Suppose if I wanted to check for all values from 2 through 5 then if I
> write
>
> if (any( w, 2 thru 5) flag2 = 67.
>
> yields an error, while writing it as
>
> if (any( w, 2,3,4, 5) flag2 = 67. works without any problem (I know i
> could have used if(range(w, 2, 5)) flag2 = 67. )
>
> I would like to know as to why does SPSS allows usage of "to" in part
> a) for specifying range of contiguous variables while in b) it doesnt
> allow usage of "thru" for specufying contiguous values.

"thru" is used for values in Recode or Missing, where it
includes the whole range, integer or non-integer.
Do you know of somewhere that it specifies discrete values?

The any() function wants an explicit, discrete list,
and it doesn't know the keyword "thru", and it would
not be consistent with other uses if it did.

--
Rich Ulrich, wpi...@pitt.edu
http://www.pitt.edu/~wpilib/index.html

0 new messages