Simple Code with less lines is possible?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple Code with less lines is possible?

Eugenio Grant
Is there a simple solution to this code.



IF (VAR1 = 1     ) VAR2 = 8.

IF (VAR1 = 3     ) VAR2 = 8.

IF (VAR1 = 8     ) VAR2 = 8.

IF (VAR1 = 90   ) VAR2 = 8.

IF (VAR1 = 1090) VAR2 = 8.

IF (VAR1 = 82) VAR2 = 8.

IF (VAR1 = 422) VAR2 = 8.

IF (VAR1 = 764) VAR2 = 8.



Something like





IF (VAR1 IN 1,2,8,90,etc) VAR2 = 8.



Regards,
Reply | Threaded
Open this post in threaded view
|

Re: Simple Code with less lines is possible?

Melissa Ives
How about: Recode var1 (1,3,8,90,etc=8(2,4,etc=x) into var2.

Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Eugenio Grant
Sent: Thursday, July 12, 2007 5:01 PM
To: [hidden email]
Subject: [SPSSX-L] Simple Code with less lines is possible?

Is there a simple solution to this code.



IF (VAR1 = 1     ) VAR2 = 8.

IF (VAR1 = 3     ) VAR2 = 8.

IF (VAR1 = 8     ) VAR2 = 8.

IF (VAR1 = 90   ) VAR2 = 8.

IF (VAR1 = 1090) VAR2 = 8.

IF (VAR1 = 82) VAR2 = 8.

IF (VAR1 = 422) VAR2 = 8.

IF (VAR1 = 764) VAR2 = 8.



Something like





IF (VAR1 IN 1,2,8,90,etc) VAR2 = 8.



Regards,


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.
Reply | Threaded
Open this post in threaded view
|

Re: Simple Code with less lines is possible?

Marks, Jim
In reply to this post by Eugenio Grant
IF ANY(var1, 1, 3, 8 ,90, 1090,82, 422, 764) var2 = 8.

If the values are text they need to be enclosed in quotations marks.


--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Eugenio Grant
Sent: Thursday, July 12, 2007 5:01 PM
To: [hidden email]
Subject: Simple Code with less lines is possible?

Is there a simple solution to this code.



IF (VAR1 = 1     ) VAR2 = 8.

IF (VAR1 = 3     ) VAR2 = 8.

IF (VAR1 = 8     ) VAR2 = 8.

IF (VAR1 = 90   ) VAR2 = 8.

IF (VAR1 = 1090) VAR2 = 8.

IF (VAR1 = 82) VAR2 = 8.

IF (VAR1 = 422) VAR2 = 8.

IF (VAR1 = 764) VAR2 = 8.



Something like





IF (VAR1 IN 1,2,8,90,etc) VAR2 = 8.



Regards,
Reply | Threaded
Open this post in threaded view
|

Re: Simple Code with less lines is possible?

Parry, James
In reply to this post by Eugenio Grant
You were so close!

IF ANY(Var1,1,3,90,1090,82,422,746) Var2=8.

The form of the ANY command is ANY(Test, Value, Value, Value)

-HTH

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Eugenio Grant
Sent: Thursday, July 12, 2007 6:01 PM
To: [hidden email]
Subject: Simple Code with less lines is possible?

Is there a simple solution to this code.



IF (VAR1 = 1     ) VAR2 = 8.

IF (VAR1 = 3     ) VAR2 = 8.

IF (VAR1 = 8     ) VAR2 = 8.

IF (VAR1 = 90   ) VAR2 = 8.

IF (VAR1 = 1090) VAR2 = 8.

IF (VAR1 = 82) VAR2 = 8.

IF (VAR1 = 422) VAR2 = 8.

IF (VAR1 = 764) VAR2 = 8.



Something like





IF (VAR1 IN 1,2,8,90,etc) VAR2 = 8.



Regards,