pspp-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PSPP Windows - Recode Multiple Variables ?


From: Andy Choens
Subject: Re: PSPP Windows - Recode Multiple Variables ?
Date: Wed, 20 Aug 2008 16:26:46 -0400
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]