Date: Sat, 14 Sep 2002 10:45:54 -0400
Reply-To: Raynald Levesque <rlevesque@videotron.ca>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Raynald Levesque <rlevesque@videotron.ca>
Subject: Re: syntax problem
In-Reply-To: <5.1.0.14.0.20020915015818.00a959a0@smtp.brisnet.org.au>
Content-type: text/plain; charset=us-ascii
Hi Bob
The following works:
DATA LIST LIST /firscene(F1) reason11(A5) secscene(F1) reason21(A5).
BEGIN DATA
1 'abc' 2 'nbh'
2 'age' 1 'mmm'
2 'nbv' 1 'mki'
1 'poi' 2 'uyt'
END DATA.
LIST.
STRING reason1a reason2a (A100).
do if firscene=1.
compute reason1a =reason11.
compute reason2a=reason21.
else.
compute reason2a=reason11.
compute reason1a=reason21.
end if.
exe.
The problem with your initial syntax is that both DO IF were checking for
the *same* condition.
firscene=1 is the same as secscene=2.
Note: using DO IF ... ELSE ... END IF is more efficient (computer time
speaking) than using 2 separate IFs.
Have fun!
Raynald Levesque rlevesque@videotron.ca
Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Bob Green
Sent: September 14, 2002 1:03 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: syntax problem
I have some syntax which doesn't quite do what I want.
Participants in research were asked why they performed a behaviour in
relation to 2 different situations. The order in which the situations were
presented varied. This resulted in data which looks like:
firscene reason1 secscene reason2
secscene reason2 firscene reason1
etc
I tried the following syntax to create 2 new variables. I want all the
reason1 data to be contained in a variable called reason1a and all the
reason2 data to be in a variable called reason2a, irrespective of order in
which it was generated.
STRING reason1a reason2a (A100).
do if firscene=1.
compute reason1a =reason11.
compute reason2a=reason21.
end if.
do if secscene=2.
compute reason2a=reason11.
compute reason1a=reason21.
end if.
exe.
Any assistance is appreciated,
regards
Bob Green