Andy (/Jason),

Many thanks for the COMPUTE suggestion and example - how is this implemented in 
the Windows/GUI version ?   I've tried various codings but with no success (and 
can't trace any other examples).

Regards,

Dave.
  ----- Original Message ----- 
  From: Andy Choens 
  To: David Purdy 
  Cc: [email protected] 
  Sent: Wednesday, August 20, 2008 9:26 PM
  Subject: Re: PSPP Windows - Recode Multiple Variables ?


  David Purdy wrote: 
    Is it possible to recode multiple sets of field values into a single new 
field ?, e.g. newfield = 1 where field1 = 5 or field2 = 5

  Yes it is. 



    And if so, how ?   TIA.   (I've checked the manual)


  Let's say I have a data set that looks like this: (sorry about the sloppy 
formatting)

  name      gender      age
  andy         1               10
  george     1               8
  sue           2               6
  karen       2               11
  billy          1               10
  fran          2               14
  mike         1               15

  I would like to have a variable that tells me which of these are boys (gender 
= 1) AND over the age of 10. Looking at the list we can easily see that mike is 
the only case that meets these criteria. But, how can we figure it out?


  COMPUTE test1 = 0 .
  IF (gender = 1) & (age > 10) test1 = 1 .
  EXECUTE .

  This will create a new variable that I've named test1, for lack of a better 
name (it's an example). Obviously, we need a TRUE / FALSE type variable, so the 
first line creates our variable AND sets it's value equal to 0 (FALSE). The 
second line looks for those cases where the conditions are met and sets test1 = 
1 (TRUE). In the end, our new dataset looks like:

  name      gender      age      test1
  andy         1               10         0
  george     1               8           0
  sue           2               6           0
  karen       2               11         0
  billy          1               10         0
  fran          2               14         0
  mike         1               15         1

  --andy

-- 
Andrew Choens, MSW
Research Policy Analyst
Hornby Zeller Associates, Inc.
(518) 273 - 1614

_______________________________________________
Pspp-users mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-users

Reply via email to