IF ANY statement with more than 1 variable AND more than 1 value

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

IF ANY statement with more than 1 variable AND more than 1 value

Ruben Geert van den Berg
Dear all,
 
I'm trying to figure out how to use an IF ANY statement with more than 1 variable AND more than 1 value:
 
IF ANY (DUM1,DUM2,DUM3,1, 0) OCC_1=1.
EXE.
 
This should render OCC_1 is 1 if either DUM1, DUM2 or DUM3 is either 1 or 0. The syntax runs without errors or
warnings but OCC_1 is not at all what I expected. Does anyone understand what I'm doing wrong?
 
TIA
 
Ruben v.d. Berg
Amsterdam, the Netherlands


What can you do with the new Windows Live? Find out
Reply | Threaded
Open this post in threaded view
|

Re: IF ANY statement with more than 1 variable AND more than 1 value

Art Kendall
I do not believe that both "sides" of the ANY function can be lists.
Open a new instance of SPSS.  Copy the syntax below to a syntax file. Click <run>. Click <all>.

data list list/id (f2) dum1 dum2 dum3 (3f1).
begin data
1 0 0 0
2 1 1 1
3 3 3 3
4 1 0 0
5 0 1 0
6 0 0 1
end data.
numeric occ_1 (f1).
compute occ_1 = 0.
IF ANY (0, DUM1,DUM2,DUM3) or
   ANY (1, DUM1,DUM2,DUM3) OCC_1=1.

*another way to do the syntax.
numeric occ_2 (f1).
compute occ_2 =
 ANY (0, DUM1,DUM2,DUM3) or
 ANY (1, DUM1,DUM2,DUM3).
list.

Art Kendall
Social Research Consultants

Ruben van den Berg wrote:
Dear all,
 
I'm trying to figure out how to use an IF ANY statement with more than 1 variable AND more than 1 value:
 
IF ANY (DUM1,DUM2,DUM3,1, 0) OCC_1=1.
EXE.
 
This should render OCC_1 is 1 if either DUM1, DUM2 or DUM3 is either 1 or 0. The syntax runs without errors or
warnings but OCC_1 is not at all what I expected. Does anyone understand what I'm doing wrong?
 
TIA
 
Ruben v.d. Berg
Amsterdam, the Netherlands


What can you do with the new Windows Live? Find out
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: IF ANY statement with more than 1 variable AND more than 1 value

Marta Garcia-Granero
In reply to this post by Ruben Geert van den Berg
Ruben van den Berg wrote:

> I'm trying to figure out how to use an IF ANY statement with more than
> 1 variable AND more than 1 value:
>
> IF ANY (DUM1,DUM2,DUM3,1, 0) OCC_1=1.
> EXE.
>
> This should render OCC_1 is 1 if either DUM1, DUM2 or DUM3 is either 1
> or 0. The syntax runs without errors or
> warnings but OCC_1 is not at all what I expected. Does
> anyone understand what I'm doing wrong?
>
>
> <http://www.microsoft.com/windows/windowslive/default.aspx>
Not absolutely sure, but I think that ANY can handle, either more than
one variable, or more than one value, but not both.

Your statement should be (notice also that I have reversed the order):

IF (ANY(1,DUM1,DUM2,DUM3) OR (ANY(0,DUM1,DUM2,DUM3) OCC_1=1.

HTH,
Marta GarcĂ­a-Granero


--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: IF ANY statement with more than 1 variable AND more than 1 value

Anthony Babinec
In reply to this post by Ruben Geert van den Berg

Make the first argument the value being checked:

 

IF ANY (0,DUM1,DUM2,DUM3) OR (1, DUM1,DUM2,DUM3) OCC_1=1.

 

Tony Babinec


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: Friday, March 13, 2009 4:33 AM
To: [hidden email]
Subject: IF ANY statement with more than 1 variable AND more than 1 value

 

Dear all,
 
I'm trying to figure out how to use an IF ANY statement with more than 1 variable AND more than 1 value:
 
IF ANY (DUM1,DUM2,DUM3,1, 0) OCC_1=1.
EXE.
 
This should render OCC_1 is 1 if either DUM1, DUM2 or DUM3 is either 1 or 0. The syntax runs without errors or
warnings but OCC_1 is not at all what I expected. Does anyone understand what I'm doing wrong?
 
TIA
 
Ruben v.d. Berg
Amsterdam, the Netherlands


What can you do with the new Windows Live? Find out

Reply | Threaded
Open this post in threaded view
|

Re: IF ANY statement with more than 1 variable AND more than 1 value

Arthur Burke
In reply to this post by Ruben Geert van den Berg
Ruben .... Try this ...
 
COMPUTE OCC_1 = RANGE(DUM1 TO DUM3, 0, 1).
EXE.
 
(Make sure DUM1, DUM2, and DUM3 are next to each other with no intervening variables).
 
Art

------------------------------------------------------------------

Art Burke
Northwest Regional Educational Laboratory
101 SW Main St, Suite 500
Portland, OR 97204-3213

Phone:  503-275-9592 / 800-547-6339

Fax: 503-275-0450

[hidden email] 

____________________________________________________________
From: Ruben van den Berg [mailto:[hidden email]]
Sent: Friday, March 13, 2009 2:33 AM
To: [hidden email]
Subject: IF ANY statement with more than 1 variable AND more than 1 value

Dear all,
 
I'm trying to figure out how to use an IF ANY statement with more than 1 variable AND more than 1 value:
 
IF ANY (DUM1,DUM2,DUM3,1, 0) OCC_1=1.
EXE.
 
This should render OCC_1 is 1 if either DUM1, DUM2 or DUM3 is either 1 or 0. The syntax runs without errors or
warnings but OCC_1 is not at all what I expected. Does anyone understand what I'm doing wrong?
 
TIA
 
Ruben v.d. Berg
Amsterdam, the Netherlands


What can you do with the new Windows Live? Find out