dimanche 30 octobre 2016

Errors with SPSS Logical Operators and Strings In a Simple Expression

I'm having some unexpected errors in achieving the following functionality. In this example code, I have the temperature on several days of the week. For this generalized example, I'm interested in determining the days that are 72,74, or 65 degrees. As an output, a variable should be created that contains the day of the week that is within this temperature range. Also, please note that in these data there is only ever 1 day that would fall within have one of these temperatures.

Monday     Tuesday     Wednesday     Day of Interest    
72         78          80            
61         78          74            



Monday     Tuesday     Wednesday     Day of Interest    
72         78          80             2  
61         78          74             4

I wrote the following code, with the generous help of the great folks here at StackOverflow,

IF (Monday = 65 OR 72 OR 74) Day_Of_Interest = 2.
IF (Tuesday= 65 OR 72 OR 74) Day_Of_Interest = 3.
IF (Wednesday = 65 OR '72' OR 74) Day_Of_Interest = 4.
IF (Thursday = 65 OR 72 OR 74) Day_Of_Interest = 5.

but sadly it returns an error:

 IF 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.'

I tried changing the code to be akin to '65' OR '72', but this produced another error. I would really appreciate if anyone had any thoughts on how to make this work. I know the example above isn't the best, but it's the best I could think of. If you need anymore details I'd be more than happy to oblige. Thanks so much for your help!

Aucun commentaire:

Enregistrer un commentaire