|
guys sorry i know this is a basic question but i cant seem to remember how i did this last time. i have one variable, age in days, and another variable, rate. i want to create a formula for rate using values fo other variables. but i have a different formula for when age is < 365 and a different one when it is >= 365. In Compute Variable, there is an option for me to select an 'if statement'. But how do I enter in two if statements, with the different formulas for each. or is there a kind of syntax i can use? thanks so much!
|
|
You can enter two IF statements in syntax:
IF (AGE LT 365) newvar=[formula 1] IF (AGE GE 365) newvar=[formula 2] You can also combine the two in a single formula with two logical conditions: COMPUTE newvar = (AGE LT 365) * [formula 1] + (AGE GE 365) * [formula 2]. In this variant, each logical condition will equal either 0 or 1, and therefore only one formula will be computed for each case. Hector -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of jimjohn Sent: 08 July 2008 14:56 To: [hidden email] Subject: compute variable using if statements guys sorry i know this is a basic question but i cant seem to remember how i did this last time. i have one variable, age in days, and another variable, rate. i want to create a formula for rate using values fo other variables. but i have a different formula for when age is < 365 and a different one when it is >= 365. In Compute Variable, there is an option for me to select an 'if statement'. But how do I enter in two if statements, with the different formulas for each. or is there a kind of syntax i can use? thanks so much! -- View this message in context: http://www.nabble.com/compute-variable-using-if-statements-tp18345270p183452 70.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Thanks!
Quoting Hector Maletta <[hidden email]>: > You can enter two IF statements in syntax: > IF (AGE LT 365) newvar=[formula 1] > IF (AGE GE 365) newvar=[formula 2] > You can also combine the two in a single formula with two logical > conditions: > COMPUTE newvar = (AGE LT 365) * [formula 1] + (AGE GE 365) * [formula 2]. > In this variant, each logical condition will equal either 0 or 1, and > therefore only one formula will be computed for each case. > > Hector > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > jimjohn > Sent: 08 July 2008 14:56 > To: [hidden email] > Subject: compute variable using if statements > > guys sorry i know this is a basic question but i cant seem to remember how i > did this last time. i have one variable, age in days, and another variable, > rate. i want to create a formula for rate using values fo other variables. > but i have a different formula for when age is < 365 and a different one > when it is >= 365. In Compute Variable, there is an option for me to select > an 'if statement'. But how do I enter in two if statements, with the > different formulas for each. or is there a kind of syntax i can use? thanks > so much! > -- > View this message in context: > http://www.nabble.com/compute-variable-using-if-statements-tp18345270p183452 > 70.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > > > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
