|
Dear ListServ members:
I have syntax that works, but there should be a more compact/elegant way of achieving the same result. Does anybody have suggestions on how to simplify this syntax? The data is longitudinal data and I am trying to categorize patterns of change over time in order to get a hands-on feel for how participants' scores are changing over time. The measure used to assess outcome is a 3-level ordinal scale and in the syntax below is represented by two variables, BLScore and FnlScore. The syntax creates a new variable, "Change_BlFnl", that categorizes the pattern of change between participants' Bl and Final visits. Here's the syntax that works: *****Create a pattern variable . COMPUTE Change_BLFnl = 0. VARIABLE LABELS Change_BLFnl 'Change Trajectory (categorized)' . IF (BLScore = 3 & FnlScore = 3) Change_BLFnl = 1 . IF (BLScore = 3 & FnlScore = 2) Change_BLFnl = 2 . IF (BLScore = 3 & FnlScore = 1) Change_BLFnl = 3 . IF (BLScore = 2 & FnlScore = 3) Change_BLFnl = 4 . IF (BLScore = 2 & FnlScore = 2) Change_BLFnl = 5 . IF (BLScore = 2 & FnlScore = 1) Change_BLFnl = 6 . IF (BLScore = 1 & FnlScore = 3) Change_BLFnl = 7 . IF (BLScore = 1 & FnlScore = 2) Change_BLFnl = 8 . IF (BLScore = 1 & FnlScore = 1) Change_BLFnl = 9 . MISSING VALUES Change_BLFnl (0) . FREQUENCIES VARIABLES=Change_BLFnl . Thanks! Daryl ===================== 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 |
|
It occurs to me that Change_BLFnl = 13 - 3*BLScore - FnlScore.
Thomas -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Daryl Schrock Sent: Wednesday, April 01, 2009 1:41 PM To: [hidden email] Subject: Syntax to simplify a series of "If" commands Dear ListServ members: I have syntax that works, but there should be a more compact/elegant way of achieving the same result. Does anybody have suggestions on how to simplify this syntax? The data is longitudinal data and I am trying to categorize patterns of change over time in order to get a hands-on feel for how participants' scores are changing over time. The measure used to assess outcome is a 3-level ordinal scale and in the syntax below is represented by two variables, BLScore and FnlScore. The syntax creates a new variable, "Change_BlFnl", that categorizes the pattern of change between participants' Bl and Final visits. Here's the syntax that works: *****Create a pattern variable . COMPUTE Change_BLFnl = 0. VARIABLE LABELS Change_BLFnl 'Change Trajectory (categorized)' . IF (BLScore = 3 & FnlScore = 3) Change_BLFnl = 1 . IF (BLScore = 3 & FnlScore = 2) Change_BLFnl = 2 . IF (BLScore = 3 & FnlScore = 1) Change_BLFnl = 3 . IF (BLScore = 2 & FnlScore = 3) Change_BLFnl = 4 . IF (BLScore = 2 & FnlScore = 2) Change_BLFnl = 5 . IF (BLScore = 2 & FnlScore = 1) Change_BLFnl = 6 . IF (BLScore = 1 & FnlScore = 3) Change_BLFnl = 7 . IF (BLScore = 1 & FnlScore = 2) Change_BLFnl = 8 . IF (BLScore = 1 & FnlScore = 1) Change_BLFnl = 9 . MISSING VALUES Change_BLFnl (0) . FREQUENCIES VARIABLES=Change_BLFnl . Thanks! Daryl ===================== 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 |
|
In reply to this post by Daryl Schrock
Dear Daryl,
I think that the following should do it (not well tested!), but it wouldn't be very polite to other folks reading your program. COMPUTE Change_BLFnl = 0. VARIABLE LABELS Change_BLFnl 'Change Trajectory (categorized)' . compute Change_BLFnl=(4-FnlScore)+((3-BLScore)*3). MISSING VALUES Change_BLFnl (0). FREQUENCIES VARIABLES=Change_BLFnl. Best, Henrik Quoting Daryl Schrock <[hidden email]>: > Dear ListServ members: > > I have syntax that works, but there should be a more compact/elegant way of > achieving the same result. Does anybody have suggestions on how to simplify > this syntax? > > The data is longitudinal data and I am trying to categorize patterns of > change over time in order to get a hands-on feel for how participants' > scores are changing over time. The measure used to assess outcome is a > 3-level ordinal scale and in the syntax below is represented by two > variables, BLScore and FnlScore. The syntax creates a new variable, > "Change_BlFnl", that categorizes the pattern of change between participants' > Bl and Final visits. > > Here's the syntax that works: > > *****Create a pattern variable . > > COMPUTE Change_BLFnl = 0. > VARIABLE LABELS Change_BLFnl 'Change Trajectory (categorized)' . > > IF (BLScore = 3 & FnlScore = 3) Change_BLFnl = 1 . > IF (BLScore = 3 & FnlScore = 2) Change_BLFnl = 2 . > IF (BLScore = 3 & FnlScore = 1) Change_BLFnl = 3 . > IF (BLScore = 2 & FnlScore = 3) Change_BLFnl = 4 . > IF (BLScore = 2 & FnlScore = 2) Change_BLFnl = 5 . > IF (BLScore = 2 & FnlScore = 1) Change_BLFnl = 6 . > IF (BLScore = 1 & FnlScore = 3) Change_BLFnl = 7 . > IF (BLScore = 1 & FnlScore = 2) Change_BLFnl = 8 . > IF (BLScore = 1 & FnlScore = 1) Change_BLFnl = 9 . > > MISSING VALUES Change_BLFnl (0) . > FREQUENCIES VARIABLES=Change_BLFnl . > > Thanks! > > Daryl > > ===================== > 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 > ************************************************************ Henrik Lolle Department of Economics, Politics and Public Administration Aalborg University Fibigerstraede 1 9200 Aalborg Phone: (+45) 99 40 81 84 ************************************************************ ===================== 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 |
