|
Hi,
I have a variables SA_times which has the number of times a person has attempted suicide. It includes '0'. I want a new variable (HxSA_times) that excludes the respondents with a value of '0' and thus counts the number of suicide attempts only when there has been at least one attempt. I thought of this but I don't know what to set Compute HxSA_times= to. Compute HxSA_times If SA_Times GE 1 HxSA_times=SA_Times If SA_Times=missing HxSA_number=missing Execute. Also tried with recode but can't figure out what to do with the '0' values except set them to missing which they really aren't. Thanks, Jan ===================== 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 |
|
Jan,
If you want a variable that is the 'number of suicide attempts given at least one attempt', a value of 0 has to be missing. There's several different ways to do that. Using recode, Recode sa_times(0=sysmis)(else=copy) into hxsa_times. It'd be better to recode 0 to a value and set that value to user missing. You'll also need to reset any usermissing values defined for sa_times Not using recode, it would be If (sa_times ge 1) hxsa_times=sa_times. Here, values of 0 and user missing are both going to go to sysmis, which you may or may not want and which can be fixed--of course. Or, Compute hxsa_times=sa_times. Missing values hxsa_times(0). Usermissing values from sa_times go to sysmis for hxsa_times. Gene Maguin Hi, I have a variables SA_times which has the number of times a person has attempted suicide. It includes '0'. I want a new variable (HxSA_times) that excludes the respondents with a value of '0' and thus counts the number of suicide attempts only when there has been at least one attempt. I thought of this but I don't know what to set Compute HxSA_times= to. Compute HxSA_times If SA_Times GE 1 HxSA_times=SA_Times If SA_Times=missing HxSA_number=missing Execute. Also tried with recode but can't figure out what to do with the '0' values except set them to missing which they really aren't. Thanks, Jan ===================== 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 J McClure
At 03:23 PM 8/25/2010, J McClure wrote:
I have a variable SA_times which has the number of times a person has Yes, they really are missing. In SPSS, 'missing' is a term of art; it means "exclude from analysis and from computation of new values". The analyst may have various reasons to mark data as 'missing'. One of those is 'didn't happen' or 'not applicable': whatever event's being studied didn't occur in that case, whether there's a value for the variable or not. For what you want to do, the non-zero number of suicide attempts is indeed 'not applicable' for subjects who've never attempted. I don't know what to set Compute HxSA_times= to. That's nowhere near the right SPSS syntax; perhaps you mean it as pseudo-code. Here's an easy way (not tested), assuming that your present SA_Times variable has no user-specified missing values: COMPUTE HxSA_times=SA_Times. MISSING VALUES HxSA_times(0). See the MISSING VALUES command, for the very useful ability to define 'user-missing' values. ===================== 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 |
