I am trying to compute an equation with mulitple variables summed multiple
times. These variables are also undergoing log transformations in the course of the equation. Problem: a number of the starting values are zero and the log transformation (rightly) doesn't like them. I was wondering if there was a good way to write the syntax such that those zero cases are skipped. I've tried an IF command with "or" separating each variable name (i.e. If (Var1>0) or (Var2>0) or ...) but this does not seem to do it. It's probably worth noting that the syntax runs, just with numberous error messages also popping up. Unfortunatly, the basic equation is two bulky (Smith and Wilson's E_Var test of Evenness if it matters) to sort of test it by hand. Any ideas? |
You need to use 'and' in your if statement if you want to include only
records where every variable is >0. or will include all variables as long as at least one of them is >0. Melissa The bubbling brook would lose its song if you removed the rocks. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of William Sent: Tuesday, April 03, 2007 1:48 AM To: [hidden email] Subject: [SPSSX-L] selecting multiple cases I am trying to compute an equation with mulitple variables summed multiple times. These variables are also undergoing log transformations in the course of the equation. Problem: a number of the starting values are zero and the log transformation (rightly) doesn't like them. I was wondering if there was a good way to write the syntax such that those zero cases are skipped. I've tried an IF command with "or" separating each variable name (i.e. If (Var1>0) or (Var2>0) or ...) but this does not seem to do it. It's probably worth noting that the syntax runs, just with numberous error messages also popping up. Unfortunatly, the basic equation is two bulky (Smith and Wilson's E_Var test of Evenness if it matters) to sort of test it by hand. Any ideas? PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for the use of the addressee. If you are not the designated recipient, or an employee or agent authorized to deliver such transmittals to the designated recipient, you are hereby notified that any dissemination, copying or publication of this transmittal is strictly prohibited. If you have received this transmittal in error, please notify us immediately by replying to the sender and delete this copy from your system. You may also call us at (309) 827-6026 for assistance. |
In reply to this post by William-85
At 02:47 AM 4/3/2007, William wrote:
>Problem: a number of [my] starting values are zero and the log >transformation (rightly) doesn't like them. I was wondering if there >was a good way to write the syntax such that those zero cases are >skipped. > >I've tried an IF command with "or" separating each variable name (i.e. >If >(Var1>0) or (Var2>0) or ...) but this does not seem to do it. Do you want a SELECT IF? That should do it, with the logic you're writing, if you want to drop cases having zero or negative values on any of those variables. There's always SELECT IF MIN(VAR1 TO VAR...) GT 0. CAREFUL: "SELECT IF" removes cases *permanently*. Make sure you have a saved copy of your complete data file. (Do this, no matter what you do.) You can use the TEMPORARY command before your SELECT IF, calculations, and procedure. Or, if you want to keep all the cases but have the log transforms come out missing for values <=0, but don't want error messages, there is IF var1 GT 0 VAR1_LOG = LG10(VAR1). Or, MISSING VALUES var1 (LO THRU 0). COMPUTE VAR1_LOG = LG10(VAR1). |
In reply to this post by William-85
>Problem: a number of [my] starting values are zero and the log
>transformation (rightly) doesn't like them. I was wondering if there >was a good way to write the syntax such that those zero cases are >skipped. My two cents: 1) Often a neater solution is to use ANY if (~any(0, var1 to var20)) foo = ln(bar). 2) Sometimes it is possible to logarithm x + 1 instead of x (or more generally to logarithm x + epsilon, epsilon > 0). With 1, zeros give zeros while large values (> 100) are almost unchanged. compute foo = ln(bar + 1). Regards Jan |
Free forum by Nabble | Edit this page |