Matching values of two string variables

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

Matching values of two string variables

Johnny Amora
Hi all,
 
I have more than 28 thousand cases.  How to check if values of two string variables  match for each case?  For example,
 
Case#    var1      var2     var3
1            XXX      XXX      match
2            YXY     XYY     not match
3                                   match but empty
4                                   match but empty
5            WWW  WWW  match
 
In that example, I created a fourth variable var3 to indicate whether values of var1 matches with var2 for each case.
 
Thanks.
Johnny
 
 
 


      Adding more friends is quick and easy.</a><br>Import them over to Yahoo! Mail today! http://www.trueswitch.com/yahoo-ph

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

תשובה: Matching values of two string variables

Nirit Avnimelech
Hi Johnny,

 

compute var3=(var1 eq var2).      /* means that if var1=var2 then var3=1, if
not, var3=0.

if (var1='   ' or var2='   ') var3=2.      /* if one or two are missing,
then var3=2.

if (var1='   ' and var2='   ') var3=3.      /* optional – if both are
missing code as "3", in case you want to differentiate between one missing
value and two missing values

 

Nirit

 

-----הודעה מקורית-----
מאת: SPSSX(r) Discussion [mailto:[hidden email]] בשם Johnny Amora
נשלח: Thursday, January 29, 2009 11:35 AM
אל: [hidden email]
נושא: Matching values of two string variables

 

Hi all,

 

I have more than 28 thousand cases.  How to check if values of two string
variables  match for each case?  For example,

 

Case#    var1      var2     var3

1            XXX      XXX      match

2            YXY     XYY     not match

3                                   match but empty

4                                   match but empty

5            WWW  WWW  match

 

In that example, I created a fourth variable var3 to indicate whether values
of var1 matches with var2 for each case.

 

Thanks.

Johnny

 

 

 

 

 

      Adding more friends is quick and easy.</a><br>Import them
over to Yahoo! Mail today! http://www.trueswitch.com/yahoo-ph

 

=======

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

R: תשובה: Matching values of two string variables

Luca Meyer-3
Actually to make sure that var3=0 in case var1<>var2 you should add to Nirit's syntax:

if var1<>var2 var3=0.

Otherwise var3 will contain some missing values.

Cheers,
Luca

www.lucameyer.com - http://collaborate2innovate.blogspot.com/


-----Messaggio originale-----
Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Nirit
Inviato: giovedì 29 gennaio 2009 12.50
A: [hidden email]
Oggetto: תשובה: Matching values of two string variables

Hi Johnny,



compute var3=(var1 eq var2).      /* means that if var1=var2 then var3=1, if
not, var3=0.

if (var1='   ' or var2='   ') var3=2.      /* if one or two are missing,
then var3=2.

if (var1='   ' and var2='   ') var3=3.      /* optional – if both are
missing code as "3", in case you want to differentiate between one missing value and two missing values



Nirit



-----הודעה מקורית-----
מאת: SPSSX(r) Discussion [mailto:[hidden email]] בשם Johnny Amora
� שלח: Thursday, January 29, 2009 11:35 AM
אל: [hidden email]
� ושא: Matching values of two string variables



Hi all,



I have more than 28 thousand cases.  How to check if values of two string variables  match for each case?  For example,



Case#    var1      var2     var3

1            XXX      XXX      match

2            YXY     XYY     not match

3                                   match but empty

4                                   match but empty

5            WWW  WWW  match



In that example, I created a fourth variable var3 to indicate whether values of var1 matches with var2 for each case.



Thanks.

Johnny











      Adding more friends is quick and easy.&lt;/a&gt;&lt;br&gt;Import them over to Yahoo! Mail today! http://www.trueswitch.com/yahoo-ph



=======

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

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

Re: R: תשובה: Matching values of two string variables

Johnny Amora
Thank you, Nirit, Lucy, et al.

My problem was solved using the syntax:

compute var3=0.                    
if (var1 eq var2) var3=1.          
if (var1=' ' or var2=' ') var3=2.
if (var1=' ' and var2=' ') var3=3.
Execute.

Cordially,
Johnny


--- On Fri, 1/30/09, Luca Meyer <[hidden email]> wrote:
From: Luca Meyer <[hidden email]>
Subject: R: תשובה: Matching values of two string variables
To: [hidden email]
Date: Friday, 30 January, 2009, 12:36 AM

Actually to make sure that var3=0 in case
 var1<>var2 you should add to
Nirit's syntax:

if var1<>var2 var3=0.

Otherwise var3 will contain some missing values.

Cheers,
Luca

www.lucameyer.com - http://collaborate2innovate.blogspot.com/


-----Messaggio originale-----
Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Nirit
Inviato: giovedì 29 gennaio 2009 12.50
A: [hidden email]
Oggetto: תשובה: Matching values of two string variables

Hi Johnny,



compute var3=(var1 eq var2). /* means that if var1=var2 then var3=1, if
not, var3=0.

if (var1=' ' or var2=' ') var3=2. /* if one or two are
missing,
then var3=2.

if (var1=' ' and var2=' ') var3=3. /* optional – if
both are
missing code as "3", in case you want to differentiate between one
missing value and two missing values



Nirit



-----הודעה מקורית-----
מאת: SPSSX(r) Discussion [mailto:[hidden email]] בשם Johnny
Amora
� שלח: Thursday, January 29, 2009 11:35 AM
אל: [hidden email]
� ושא: Matching values of two string variables



Hi all,



I have more than 28 thousand cases. How to check if values of two string
variables match for each case? For example,



Case# var1 var2 var3

1 XXX XXX match

2 YXY XYY not match

3 match but empty

4 match but empty

5 WWW WWW match



In that example, I created a fourth variable var3 to indicate whether values of
var1 matches with var2 for each case.



Thanks.

Johnny











Adding more friends is quick and
easy.&lt;/a&gt;&lt;br&gt;Import them over to Yahoo! Mail today!
http://www.trueswitch.com/yahoo-ph



=======

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

=====================
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


Show off your style with new cool skins.
Try the all-new Yahoo! Messenger 9.0 today!