David Purdy wrote:
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.
What I wrote should work on the windows version too. I'm not real sure
how (if) you can use the GUI to actually recode multiple variables into
one. Although the GUI is fairly powerful, I'm not sure that capacity
exists yet. (Others here may correct me. In all honesty, I don't even
know how to do this on SPSS through the GUI.)
I usually find the GUI most useful for helping me to remember my
variables. Variable view is your friend. Otherwise I have little use
for it all. Learning how to read / write PSPP syntax is going to open
up all sorts of new possibilities for you that the GUI will never be
able to match.
Advantages include:
1) Reproducibility - you know what you did (every last detail)
2) Reproducibility - you can do it over and over again (very quickly),
when necessary.
3) mailing-list. It's easier to write code here than to send you
screenshots.
4) Speed - You can type faster than you can click (and cut and paste is
nice too!)
If you want to use my example, use the GUI to input the variables and
cases. Then go to File -> New -> Syntax and cut and paste my
syntax (code) into the syntax window. Make sure you get ALL of it,
including the periods (It won't work without the periods.) Then Run
-> All.
SPSS syntax doesn't have to be a full coding experience. For small,
quick projects I often open up the .sav file, type in some syntax and
tell it to go. In SPSS I'll use the GUI to tweak my tables a little
(titles, etc.) but most of my work is done in the syntax.
-----
Original Message -----
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
--
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