I'm trying to create two new condition variables by using the following syntax:
IF condition='P'x1powercond=1. IF condition='N'x1powercond=-1. IF condition='P'x2powercond=-1. IF condition='N'x2powercond=1. EXECUTE. But I keep getting the following error message: >Error # 4305 in column 17. Text: x1powercond >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. >Execution of this command stops. When I check with variable view, however, all of the variables are set to either numeric or scale...not to string. |
I've never tried putting one variable after a quoted string
without leaving a blank. I suspect that SPSS fails to parse, for that reason. In any case, it is clearer to use, RECODE condition('P'=1)('N'=1) into x1powercond. - similarly, for the second one. Or, COMPUTE X2powercond= 0 - x1powercond. - assuming <condition> in your example was the name of a variable, and not just a place-holder, and you want a reversed variable. -- Rich Ulrich > Date: Mon, 28 May 2012 22:11:20 -0700 > From: [hidden email] > Subject: Error 4305 with Syntax > To: [hidden email] > > I'm trying to create two new condition variables by using the following > syntax: > > > IF condition='P'x1powercond=1. > IF condition='N'x1powercond=-1. > IF condition='P'x2powercond=-1. > IF condition='N'x2powercond=1. > EXECUTE. > > > But I keep getting the following error message: > > >Error # 4305 in column 17. Text: x1powercond > >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. > >Execution of this command stops. > > When I check with variable view, however, all of the variables are set to > either numeric or scale...not to string. > >... |
In reply to this post by nato123
El 29/05/2012 7:11, nato123 escribió:
> I'm trying to create two new condition variables by using the following > syntax: > > > IF condition='P'x1powercond=1. > IF condition='N'x1powercond=-1. > IF condition='P'x2powercond=-1. > IF condition='N'x2powercond=1. > EXECUTE. Insert a space between ' and x: IF condition='P' x1powercond=1. IF condition='N' x1powercond=-1. IF condition='P' x2powercond=-1. IF condition='N' x2powercond=1. EXECUTE. I tried it and it works OK. HTH, Marta GG ===================== 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 |
Separate from what Marta said, is condition defined as a string variable? As I read the error message, the problem is a data types mismatch between the two elements being compared.
Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero Sent: Tuesday, May 29, 2012 2:13 AM To: [hidden email] Subject: Re: Error 4305 with Syntax El 29/05/2012 7:11, nato123 escribió: > I'm trying to create two new condition variables by using the > following > syntax: > > > IF condition='P'x1powercond=1. > IF condition='N'x1powercond=-1. > IF condition='P'x2powercond=-1. > IF condition='N'x2powercond=1. > EXECUTE. IF condition='P' x1powercond=1. IF condition='N' x1powercond=-1. IF condition='P' x2powercond=-1. IF condition='N' x2powercond=1. EXECUTE. I tried it and it works OK. HTH, Marta GG ===================== 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 |