|
|
Ismail,
You need to read up on Do if-End if commands in the syntax reference manual. You are allowed exactly ONE Do if, one or more Else if's and exactly ONE Else statement in a Do if-End if structure. Change all but one of your Do if's to Else if's. In addition, you have to have periods at the end of statements. Gene Maguin >>Can some one tell me what is wrong with this syntax? Every time and run it it SPSS give me an error that reads like this: >Error # 4305 in column 1. Text: COMPUTE >A relational operator may have two numeric operands or two character string >operands. To compare a character string to a numeric quantity, consider using >the STRING or NUMBER function. >This command not executed. Do IF howoldareyou='4' Compute weightage=0/3. This is the Syntax........ DATASET ACTIVATE DataSet3. COMPUTE weightage=15/8. Do IF howoldareyou='1' COMPUTE weightage=26/19. Do IF howoldareyou='2' COMPUTE weightage=32/40. Do IF howoldareyou='3' COMPUTE weightage=26/31. Do IF howoldareyou='4' Compute weightage=0/3. Do IF howoldareyou='5' End If. EXECUTE . Thanks......... Ismail K. Noor, Ph.D., [hidden email] http://www.dennonoor.com (313) 690-0755 (cell) ===================== 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 Ismail Noor
You do not have a period after the DO IF
commands, so SPSS thinks the next COMPUTE is a continuation of the DO IF
command. It should be Do IF howoldareyou='1'. By the way, you do not need the DO IF. An IF command
would suffice, replacing bot DO IF and COMPUTE: For instance: IF (howoldareyou='1') weightage=26/19. And so on Hector From: SPSSX(r)
Discussion
|
|
In reply to this post by Ismail Noor
Hi
You are missing a "." at the end of your DO IF lines. Regards Raynald Levesque www.spsstools.net On Sun, May 31, 2009 at 1:38 PM, Ismail Noor <[hidden email]> wrote:
|
|
In reply to this post by Ismail Noor
Hi Ismail, A question: what should the program do, if howoldareyou='5' ? Should compute weightage to 0/3 ? I have a slight feeling, that you put the transformation command before the do if statement... So if you want weightage to be 15/8 when howoldareyou='1', than you first need to check wheather howoldareyou is equal with '1' : DATASET ACTIVATE DataSet3. Do IF howoldareyou='1'. COMPUTE weightage=15/8. Else IF howoldareyou='2'. COMPUTE weightage=26/19. Else IF howoldareyou='3'. COMPUTE weightage=32/40. Else IF howoldareyou='4'. COMPUTE weightage=26/31. Else IF howoldareyou='5'. Compute weightage=0/3. End If. EXECUTE . From: Ismail Noor <[hidden email]> To: [hidden email] Sent: Sunday, May 31, 2009 8:38:41 PM Subject: compute + do if commands
|
|
In reply to this post by Ismail Noor
Dear Ismail,
The variable weightage doesn't exist before you run the syntax below, right? I'd expect an error like you posted if weightage would have been previously declared a string variable (or preexisted in your data as a string variable). Kind regards, Ruben Date: Sun, 31 May 2009 10:38:41 -0700 From: [hidden email] Subject: compute + do if commands To: [hidden email]
What can you do with the new Windows Live? Find out |
| Free forum by Nabble | Edit this page |
