Login  Register

Re: Repeat case equals VAR

Posted by David Marso on Mar 30, 2013; 12:00am
URL: http://spssx-discussion.165.s1.nabble.com/Repeat-case-equals-VAR-tp5719153p5719189.html

From Peter's example that is unlikely.
Look at my advice.  That guts the fish as presented.
But I'm not writing any more code tonight!
Peter needs to present a clearer example.
THIS is NOT TWITTER!
Do I need to bump my "how to ask questions thread again" ?????
-----
Bruce Weaver wrote
Ah, is that what the OP meant?  What if all 3 variables are the same?

DATA LIST Free / V1 V2 V3.
BEGIN DATA
1 1 2
3 2 3
3 2 2
3 3 3
END DATA.

STRING NEWVAR (A10).
DO IF SD.3(V1,V2,V3) EQ 0.
- Compute NEWVAR="V1,V2,V3".
ELSE IF (V1=V2).
- Compute NEWVAR="V1,V2".
ELSE IF (V2=V3).
- COMPUTE NEWVAR="V2,V3".
ELSE IF (V1=V3).
- COMPUTE NEWVAR = "V1,V3".
END IF .
LIST .


Ujjawal wrote
DATA LIST Free / V1 V2 V3.
BEGIN DATA
1 1 2
3 2 3
3 2 2
END DATA.

STRING NEWVAR (A10).
DO IF (V1=V2).
Compute NEWVAR="V1,V2".
ELSE IF (V2=V3).
COMPUTE NEWVAR="V2,V3".
ELSE IF (V1=V3).
COMPUTE NEWVAR = "V1,V3".
END IF .
LIST .

      V1       V2       V3 NEWVAR
 
    1.00     1.00     2.00 V1,V2
    3.00     2.00     3.00 V1,V3
    3.00     2.00     2.00 V2,V3
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"