# spssforum.com

by SPSS users, for SPSS users
 It is currently Wed May 22, 2013 2:39 pm

 All times are UTC

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: IF THEN Statements in SPSS 19.0Posted: Wed Jun 06, 2012 5:12 pm

Joined: Wed Jun 06, 2012 4:51 pm
Posts: 5
I have a complicated (to me, anyway) scoring procedure and I am trying to determine the easiest approach. I think some kind of IF (...) THEN (...) set up will work. I have some dietary data with a frequency of consumption (codes ranging from 0 to 2.0). There are 15 different food items which results in 15 different frequency of consumption responses. I am supposed to take each one of those and multiply it by a corresponding portion size value. These portion sizes are not only dependent on the type of food (of the 15) but also the portion size value differs by the respondents gender (male or female) and age grouping (18-27, 28-37...78+). For example, for a person who reports consuming skim milk 2 times per day and is a 19 year old female, I would have to multiply 2 (consumption frequency) by 245.0 (the corresponding portion size for a 19 year old female); if everything else were the same but the respondent was male, I would have to multiply 2 by 366.7. In the end all the products for each food (15 total) will be added together for the final score.

I am thinking the best way is to do each food one at a time and then just have some sort of IF THEN statement for whether they are male or female and what age grouping they belong in to dictate what portion size to multiply the frequency by.

Any thoughts?

If it helps, this is an online site for the actual scoring procedures that I am using http://riskfactor.cancer.gov/diet/scree ... html...all based in SAS. I am using SPSS 19.0.

Top

 Post subject: Re: IF THEN Statements in SPSS 19.0Posted: Fri Jun 08, 2012 1:41 am

Joined: Thu Apr 05, 2012 5:58 pm
Posts: 463
The SAS syntax is pretty straight forward, I transcribed it into SPSS here. Check carefully and use it at your own risk.

Code:
* SPSS conversion of the syntax hosted on http://riskfactor.cancer.gov/diet/screeners/fat/scoring.html .

DEFINE !part1 (var01 = !TOKENS(1)/
var02 = !TOKENS(1))
IF !var01 = 1 !var02 = 0 .
IF !var01 = 2 !var02 = .018 .
IF !var01 = 3 !var02 = .066 .
IF !var01 = 4 !var02 = .214 .
IF !var01 = 5 !var02 = .499 .
IF !var01 = 6 !var02 = .784 .
IF !var01 = 7 !var02 = 1 .
IF !var01 = 8 !var02 = 2 .
IF !var01 = 9 OR SYSMIS(!var01) !var02 = SYSMIS(!var02) .
!ENDDEFINE .
EXECUTE .

!part1 var01 = cereal var02 = F2 .
!part1 var01 = skimmilk var02 = F3.
!part1 var01 = eggs var02 = F4 .
!part1 var01 = sausage var02 = F5 .
!part1 var01 = margbr var02 = F6 .
!part1 var01 = citjuice var02 = F7 .
!part1 var01 = fruit var02 = F8 .
!part1 var01 = hotdog var02 = F9 .
!part1 var01 = cheese var02 = F10 .
!part1 var01 = friedpot var02 = F11 .
!part1 var01 = margveg var02 = F12 .
!part1 var01 = mayo var02 = F13 .
!part1 var01 = saldrs var02 = F14 .
!part1 var01 = rice var02 = F15 .
!part1 var01 = margrice var02 = F16 .
EXECUTE .

* Put in your variable label here. I typed 2 for you as example: .
VARIABLE LABELS
F2 "Cold cereal"
F3 "Skim milk"
F4 "Eggs"
F5 "Sausage"
F7 "Orange juice"
F8 "Fruit"
F9 "Hot dogs"
F10 "Cheese"
F11 "French fries"
F12 "Marg-2 veg"
F13 "Mayo"
F15 "Rice"
F16 "Marg-3, rice" .
EXECUTE .

COMPUTE totfat = SUM(F6, F12, F16) .
EXECUTE .

IF lofatmrg <= 2 fatreal = 1 .
IF lofatmrg = 3  fatreal = .75 .
IF lofatmrg = 4  fatreal = .5 .
IF lofatmrg = 5  fatreal = .25 .
IF lofatmrg = 6  fatreal = 0 .
IF lofatmrg <= 2 dietfat = 0 .
IF lofatmrg = 3  dietfat = .25 .
IF lofatmrg = 4  dietfat = .5 .
IF lofatmrg = 5  dietfat = .75 .
IF lofatmrg = 6  dietfat = 1 .
EXECUTE .

COMPUTE regfat = fatreal * totfat .
EXECUTE .

DO IF gender = 1 & age >= 18 and age < 28 .
COMPUTE F2A=74.666667*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=114.000000*F9 .
COMPUTE F7A=373.200000*F7 .
COMPUTE F10A=33.360000*F10 .
COMPUTE F11A=112.500000*F11 .
COMPUTE F3A=366.666667*F3 .
COMPUTE F5A=25.000000*F5 .
COMPUTE F8A=131.750000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=36.720000*F14 .
COMPUTE REGFATA=9.540000*REGFAT .
COMPUTE F15A=213.625000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 28 and age < 38 .
COMPUTE F2A=61.500000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=85.500000*F9 .
COMPUTE F7A=311.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=114.000000*F11 .
COMPUTE F3A=250.000000*F3 .
COMPUTE F5A=40.250000*F5 .
COMPUTE F8A=128.000000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=44.060000*F14 .
COMPUTE REGFATA=9.540000*REGFAT .
COMPUTE F15A=195.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 38 and age < 48 .
COMPUTE F2A=57.500000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=88.000000*F9 .
COMPUTE F7A=249.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=100.000000*F11 .
COMPUTE F3A=250.000000*F3 .
COMPUTE F5A=32.000000*F5 .
COMPUTE F8A=123.200000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=31.250000*F14 .
COMPUTE REGFATA=9.460000*REGFAT .
COMPUTE F15A=166.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 48 and age < 58 .
COMPUTE F2A=56.000000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=114.000000*F9 .
COMPUTE F7A=249.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=100.000000*F11 .
COMPUTE F3A=245.000000*F3 .
COMPUTE F5A=32.000000*F5 .
COMPUTE F8A=127.500000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=31.250000*F14 .
COMPUTE REGFATA=9.200000*REGFAT .
COMPUTE F15A=165.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 58 and age < 68 .
COMPUTE F2A=46.000000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=248.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=85.500000*F11 .
COMPUTE F3A=214.375000*F3 .
COMPUTE F5A=27.000000*F5 .
COMPUTE F8A=122.000000*F8 .
COMPUTE F13A=9.150000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=7.883333*REGFAT .
COMPUTE F15A=165.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 68 and age < 78 .
COMPUTE F2A=39.000000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=24.000000*F10 .
COMPUTE F11A=85.500000*F11 .
COMPUTE F3A=198.937500*F3 .
COMPUTE F5A=26.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=7.100000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 78.
COMPUTE F2A=33.000000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=22.880000*F10 .
COMPUTE F11A=97.000000*F11 .
COMPUTE F3A=160.725000*F3 .
COMPUTE F5A=24.000000*F5 .
COMPUTE F8A=114.250000*F8 .
COMPUTE F13A=4.580000*F13 .
COMPUTE F14A=29.380000*F14 .
COMPUTE REGFATA=7.000000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 18 and age < 28 .
COMPUTE F2A=50.000000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=249.000000*F7 .
COMPUTE F10A=26.175000*F10 .
COMPUTE F11A=79.500000*F11 .
COMPUTE F3A=245.000000*F3 .
COMPUTE F5A=26.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=30.630000*F14 .
COMPUTE REGFATA=7.000000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 28 and age < 38 .
COMPUTE F2A=49.500000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=248.800000*F7 .
COMPUTE F10A=21.000000*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=245.000000*F3 .
COMPUTE F5A=25.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=6.880000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=6.290000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 38 and age < 48 .
COMPUTE F2A=44.000000*F2 .
COMPUTE F4A=69.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=248.800000*F7 .
COMPUTE F10A=22.500000*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=244.800000*F3 .
COMPUTE F5A=24.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=9.170000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=5.925000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 48 and age < 58 .
COMPUTE F2A=43.500000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=114.000000*F9 .
COMPUTE F7A=217.875000*F7 .
COMPUTE F10A=22.063333*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=229.690000*F3 .
COMPUTE F5A=24.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=9.183333*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=7.095000*REGFAT .
COMPUTE F15A=155.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 58 and age < 68 .
COMPUTE F2A=33.000000*F2 .
COMPUTE F4A=68.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=24.000000*F10 .
COMPUTE F11A=66.000000*F11 .
COMPUTE F3A=196.000000*F3 .
COMPUTE F5A=18.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=6.110000*F13 .
COMPUTE F14A=29.380000*F14 .
COMPUTE REGFATA=5.296667*REGFAT .
COMPUTE F15A=122.250000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 68 and age < 78 .
COMPUTE F2A=33.000000*F2 .
COMPUTE F4A=56.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.600000*F7 .
COMPUTE F10A=21.000000*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=183.750000*F3 .
COMPUTE F5A=19.500000*F5 .
COMPUTE F8A=112.427143*F8 .
COMPUTE F13A=10.310000*F13 .
COMPUTE F14A=29.380000*F14 .
COMPUTE REGFATA=5.320000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 78 .
COMPUTE F2A=33.500000*F2 .
COMPUTE F4A=46.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=25.800000*F10 .
COMPUTE F11A=64.000000*F11 .
COMPUTE F3A=183.750000*F3 .
COMPUTE F5A=16.000000*F5 .
COMPUTE F8A=109.000000*F8 .
COMPUTE F13A=4.580000*F13 .
COMPUTE F14A=22.030000*F14 .
COMPUTE REGFATA=4.865000*REGFAT .
COMPUTE F15A=83.000000*F15 .
END IF .
EXECUTE .

IF gender = 1 predict_pcf = 30.795765 - (0.022086*F2A) - (0.009666*F3A) +
(0.026997*F4A) + (0.109569*F5A) - (0.004946*F7A)
- (0.009346*F8A) +
(0.040118*F9A) + (0.069945*F10A) + (0.024262*F11A) +
(0.145026*F13A) + (0.114649*F14A) - (0.017017*F15A) +
(0.167937*REGFATA) .
EXECUTE .

IF gender = 2 predict_pcf = 29.865870 - (0.045171*F2A) - (0.010393*F3A) +
(0.036787*F4A) + (0.198808*F5A) - (0.010141*F7A)
- (0.012103*F8A) +
(0.106686*F9A) + (0.103239*F10A) + (0.040374*F11A) +
(0.287044*F13A) + (0.182758*F14A) - (0.014224*F15A) +
(0.326702*REGFATA) .
EXECUTE .

Top

 Post subject: Re: IF THEN Statements in SPSS 19.0Posted: Mon Jun 11, 2012 8:24 pm

Joined: Wed Jun 06, 2012 4:51 pm
Posts: 5
Thanks so much! I will give it a try and let you know if I was successful.

Top

 Post subject: Re: IF THEN Statements in SPSS 19.0Posted: Tue Jun 12, 2012 8:43 pm

Joined: Wed Jun 06, 2012 4:51 pm
Posts: 5
I have saved the below code as a UTF-8 file and am trying to run it via the "Run Script" option in SPSS 19.0. I did rename the variables to match the ones in my data set. I keep getting this error message: Error : Expecting 'Declare | Delegate | Event | Function | Property | Sub | Const | Dim | Private | Public | Friend | Enum | Type' At Line No : 1

Not really sure what that is about. Any suggestions?

DEFINE !part1 (var01 = !TOKENS(1)/
var02 = !TOKENS(1))
IF !var01 = 1 !var02 = 0 .
IF !var01 = 2 !var02 = .018 .
IF !var01 = 3 !var02 = .066 .
IF !var01 = 4 !var02 = .214 .
IF !var01 = 5 !var02 = .499 .
IF !var01 = 6 !var02 = .784 .
IF !var01 = 7 !var02 = 1 .
IF !var01 = 8 !var02 = 2 .
IF !var01 = 9 OR SYSMIS(!var01) !var02 = SYSMIS(!var02) .
!ENDDEFINE .
EXECUTE .

!part1 var01 = X14_1 var02 = F2 .
!part1 var01 = X14_2 var02 = F3.
!part1 var01 = X14_3 var02 = F4 .
!part1 var01 = X14_4 var02 = F5 .
!part1 var01 = X14_5 var02 = F6 .
!part1 var01 = X14_6 var02 = F7 .
!part1 var01 = X14_7 var02 = F8 .
!part1 var01 = X14_8 var02 = F9 .
!part1 var01 = X14_9 var02 = F10 .
!part1 var01 = X14_10 var02 = F11 .
!part1 var01 = X14_11 var02 = F12 .
!part1 var01 = X14_12 var02 = F13 .
!part1 var01 = X14_13 var02 = F14 .
!part1 var01 = X14_14 var02 = F15 .
!part1 var01 = X14_15 var02 = F16 .
EXECUTE .

VARIABLE LABELS
F2 "X14_1"
F3 "X14_2"
F4 "X14_3"
F5 "X14-4"
F6 "X14_5"
F7 "X14_6"
F8 "X14_7"
F9 "X14_8"
F10 "X14_9"
F11 "X14_10"
F12 "X14_11"
F13 "X14_12"
F14 "X14_13"
F15 "X14_14"
F16 "X14_15" .
EXECUTE .

COMPUTE totfat = SUM(F6, F12, F16) .
EXECUTE .

IF lofatmrg <= 2 fatreal = 1 .
IF lofatmrg = 3 fatreal = .75 .
IF lofatmrg = 4 fatreal = .5 .
IF lofatmrg = 5 fatreal = .25 .
IF lofatmrg = 6 fatreal = 0 .
IF lofatmrg <= 2 dietfat = 0 .
IF lofatmrg = 3 dietfat = .25 .
IF lofatmrg = 4 dietfat = .5 .
IF lofatmrg = 5 dietfat = .75 .
IF lofatmrg = 6 dietfat = 1 .
EXECUTE .

COMPUTE regfat = fatreal * totfat .
EXECUTE .

DO IF gender = 1 & age >= 18 and age < 28 .
COMPUTE F2A=74.666667*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=114.000000*F9 .
COMPUTE F7A=373.200000*F7 .
COMPUTE F10A=33.360000*F10 .
COMPUTE F11A=112.500000*F11 .
COMPUTE F3A=366.666667*F3 .
COMPUTE F5A=25.000000*F5 .
COMPUTE F8A=131.750000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=36.720000*F14 .
COMPUTE REGFATA=9.540000*REGFAT .
COMPUTE F15A=213.625000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 28 and age < 38 .
COMPUTE F2A=61.500000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=85.500000*F9 .
COMPUTE F7A=311.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=114.000000*F11 .
COMPUTE F3A=250.000000*F3 .
COMPUTE F5A=40.250000*F5 .
COMPUTE F8A=128.000000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=44.060000*F14 .
COMPUTE REGFATA=9.540000*REGFAT .
COMPUTE F15A=195.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 38 and age < 48 .
COMPUTE F2A=57.500000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=88.000000*F9 .
COMPUTE F7A=249.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=100.000000*F11 .
COMPUTE F3A=250.000000*F3 .
COMPUTE F5A=32.000000*F5 .
COMPUTE F8A=123.200000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=31.250000*F14 .
COMPUTE REGFATA=9.460000*REGFAT .
COMPUTE F15A=166.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 48 and age < 58 .
COMPUTE F2A=56.000000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=114.000000*F9 .
COMPUTE F7A=249.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=100.000000*F11 .
COMPUTE F3A=245.000000*F3 .
COMPUTE F5A=32.000000*F5 .
COMPUTE F8A=127.500000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=31.250000*F14 .
COMPUTE REGFATA=9.200000*REGFAT .
COMPUTE F15A=165.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 58 and age < 68 .
COMPUTE F2A=46.000000*F2 .
COMPUTE F4A=92.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=248.000000*F7 .
COMPUTE F10A=28.350000*F10 .
COMPUTE F11A=85.500000*F11 .
COMPUTE F3A=214.375000*F3 .
COMPUTE F5A=27.000000*F5 .
COMPUTE F8A=122.000000*F8 .
COMPUTE F13A=9.150000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=7.883333*REGFAT .
COMPUTE F15A=165.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 68 and age < 78 .
COMPUTE F2A=39.000000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=24.000000*F10 .
COMPUTE F11A=85.500000*F11 .
COMPUTE F3A=198.937500*F3 .
COMPUTE F5A=26.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=7.100000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 1 & age >= 78.
COMPUTE F2A=33.000000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=22.880000*F10 .
COMPUTE F11A=97.000000*F11 .
COMPUTE F3A=160.725000*F3 .
COMPUTE F5A=24.000000*F5 .
COMPUTE F8A=114.250000*F8 .
COMPUTE F13A=4.580000*F13 .
COMPUTE F14A=29.380000*F14 .
COMPUTE REGFATA=7.000000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 18 and age < 28 .
COMPUTE F2A=50.000000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=249.000000*F7 .
COMPUTE F10A=26.175000*F10 .
COMPUTE F11A=79.500000*F11 .
COMPUTE F3A=245.000000*F3 .
COMPUTE F5A=26.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=13.750000*F13 .
COMPUTE F14A=30.630000*F14 .
COMPUTE REGFATA=7.000000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 28 and age < 38 .
COMPUTE F2A=49.500000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=248.800000*F7 .
COMPUTE F10A=21.000000*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=245.000000*F3 .
COMPUTE F5A=25.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=6.880000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=6.290000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 38 and age < 48 .
COMPUTE F2A=44.000000*F2 .
COMPUTE F4A=69.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=248.800000*F7 .
COMPUTE F10A=22.500000*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=244.800000*F3 .
COMPUTE F5A=24.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=9.170000*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=5.925000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 48 and age < 58 .
COMPUTE F2A=43.500000*F2 .
COMPUTE F4A=80.000000*F4 .
COMPUTE F9A=114.000000*F9 .
COMPUTE F7A=217.875000*F7 .
COMPUTE F10A=22.063333*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=229.690000*F3 .
COMPUTE F5A=24.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=9.183333*F13 .
COMPUTE F14A=29.400000*F14 .
COMPUTE REGFATA=7.095000*REGFAT .
COMPUTE F15A=155.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 58 and age < 68 .
COMPUTE F2A=33.000000*F2 .
COMPUTE F4A=68.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=24.000000*F10 .
COMPUTE F11A=66.000000*F11 .
COMPUTE F3A=196.000000*F3 .
COMPUTE F5A=18.000000*F5 .
COMPUTE F8A=118.000000*F8 .
COMPUTE F13A=6.110000*F13 .
COMPUTE F14A=29.380000*F14 .
COMPUTE REGFATA=5.296667*REGFAT .
COMPUTE F15A=122.250000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 68 and age < 78 .
COMPUTE F2A=33.000000*F2 .
COMPUTE F4A=56.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.600000*F7 .
COMPUTE F10A=21.000000*F10 .
COMPUTE F11A=70.000000*F11 .
COMPUTE F3A=183.750000*F3 .
COMPUTE F5A=19.500000*F5 .
COMPUTE F8A=112.427143*F8 .
COMPUTE F13A=10.310000*F13 .
COMPUTE F14A=29.380000*F14 .
COMPUTE REGFATA=5.320000*REGFAT .
COMPUTE F15A=158.000000*F15 .
END IF .
EXECUTE .

DO IF gender = 2 & age >= 78 .
COMPUTE F2A=33.500000*F2 .
COMPUTE F4A=46.000000*F4 .
COMPUTE F9A=57.000000*F9 .
COMPUTE F7A=186.750000*F7 .
COMPUTE F10A=25.800000*F10 .
COMPUTE F11A=64.000000*F11 .
COMPUTE F3A=183.750000*F3 .
COMPUTE F5A=16.000000*F5 .
COMPUTE F8A=109.000000*F8 .
COMPUTE F13A=4.580000*F13 .
COMPUTE F14A=22.030000*F14 .
COMPUTE REGFATA=4.865000*REGFAT .
COMPUTE F15A=83.000000*F15 .
END IF .
EXECUTE .

IF gender = 1 predict_pcf = 30.795765 - (0.022086*F2A) - (0.009666*F3A) +
(0.026997*F4A) + (0.109569*F5A) - (0.004946*F7A)
- (0.009346*F8A) +
(0.040118*F9A) + (0.069945*F10A) + (0.024262*F11A) +
(0.145026*F13A) + (0.114649*F14A) - (0.017017*F15A) +
(0.167937*REGFATA) .
EXECUTE .

IF gender = 2 predict_pcf = 29.865870 - (0.045171*F2A) - (0.010393*F3A) +
(0.036787*F4A) + (0.198808*F5A) - (0.010141*F7A)
- (0.012103*F8A) +
(0.106686*F9A) + (0.103239*F10A) + (0.040374*F11A) +
(0.287044*F13A) + (0.182758*F14A) - (0.014224*F15A) +
(0.326702*REGFATA) .
EXECUTE .

Top

 Post subject: Re: IF THEN Statements in SPSS 19.0Posted: Tue Jun 12, 2012 9:32 pm

Joined: Thu Apr 05, 2012 5:58 pm
Posts: 463
I will suggest:

Go to File, New, Syntax
Copy and paste the whole code into the syntax window
Make necessary renaming of variables
Save the stntax as a file somewhere
Now back tithe syntax file, choose Run

Top

 Post subject: Re: IF THEN Statements in SPSS 19.0Posted: Wed Jun 13, 2012 6:07 pm

Joined: Wed Jun 06, 2012 4:51 pm
Posts: 5
Yes, I have read that. It seems this version I have at work does not have a File-->New option. I will check the version I have at home which is spiffier. At work, I do have the latest SPSS 19.0 desktop version...

Top

 Post subject: Posted: Wed Jun 13, 2012 6:15 pm

Joined: Wed Jun 06, 2012 4:51 pm
Posts: 5
Maybe I am messing up with the variable label names. You stated for me to put them in there and that you typed two as an example. However, I did not see two that you typed, only the list after Variable names and thought you typed them all.

Top

 Post subject: Re: IF THEN Statements in SPSS 19.0Posted: Wed Jun 13, 2012 6:28 pm

Joined: Thu Apr 05, 2012 5:58 pm
Posts: 463
Yes. I typed two at first but then went back to complete it, just for completion's sake.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 8 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ SPSS    General    Data input    Output    SPSS for beginners    Enhancing data    Modifying SPSS output    Coding SPSS syntax SPSS the software    Errors    Where is .. in SPSS Statistics    Statistics for beginners    Heavy statistics SPSS Jobs    SPSS Jobs SPSS Forum    Read this first    General feedback or questions about this forum    Library