Date: Thu, 13 Oct 2005 23:02:16 -0400
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: do if structure not populating new vars
Content-Type: text/plain; charset=us-ascii
"Raffe, Sydelle, SSA" <DRaffe@ACGOV.ORG> wrote on Oct 13, 2005 8:30 PM
> I have a data file partly composed of the fields fbu, aidtype and seq. I want
> to create new variables called fbu1, fbu2, aidtype1, aidtype2. The logic I
> tried for fbu1 and fbu2 follows the data table. SPSS doesn't complain bu
>t it doesn't populate the fields. I apreciate your help as always.
fbu aidtype seq fbu1 fbu2 aidtype1 aidtype2
09 09B 1
90 966 2
09 09B 1
90 966 2
09 09K 1
90 966 2
09 09B 1
90 966 2
string fbu1 fbu2(a2)/aidtype1 aidtype2(a3).
do if (seq eq '1').
compute fbu1 = fbu.
else if (seq eq '2').
compute fbu2 = fbu.
end if.
execute.
........
To start: Failure to complain doesn't mean much. SPSS is quite happy to execute none of the branches of a DO IF structure, if no test succeeds. That's as designed.
I trust that "seq" is of string datatype? I don't even remember what happens if you try to compare a string with a numeric quantity. (I'm away from my desk, and have no working copy of SPSS.)
For diagnostic, try this:
String logic (A8).
Compute LOGIC = 'MISSING'.
do if (seq eq '1').
COMPUTE LOGIC = 'SUCCEED1'.
compute fbu1 = fbu.
else if (seq eq '2').
COMPUTE LOGIC = 'SUCCEED2'.
compute fbu2 = fbu.
ELSE.
Compute logic = 'FAILED'.
end if.