Compare string variables

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

Compare string variables

ANDRES ALBERTO BURGA LEON

Helo to everybody:
 
I have four string variables (paterno_c1, paterno_c2 paterno_m1, paterno_2) and almost 200000 cases
 
I want to compare if the content of any of the four variables is diferent.
 
So far I've come with:
 
DO REPEAT X = paterno_c2 paterno_m1 paterno_m2.
IF  (paterno_c1   ~=   X) paterno_diferentes=1.
END REPEAT PRINT.
DO REPEAT X = paterno_m1 paterno_m2.
IF  (paterno_c2   ~=   X) paterno_diferentes=1.
END REPEAT PRINT.
IF  (paterno_m1   ~=   paterno_m2) paterno_diferentes=1.
EXECUTE.
Wich gave me what I want. I wonder if this could be done with fever lines of if there is a more eficient way to do this
 
Thank you very much
====================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: Compare string variables

David Marso
Administrator
IF (MIN(varlist) NE MAX(varlist)) .......
......

ANDRES ALBERTO BURGA LEON wrote
Helo to everybody:
 
I have four string variables (paterno_c1, paterno_c2 paterno_m1, paterno_2) and almost 200000 cases
 
I want to compare if the content of any of the four variables is diferent.
 
So far I've come with:
 
DO REPEAT X = paterno_c2 paterno_m1 paterno_m2. IF  (paterno_c1   ~=   X) paterno_diferentes=1. END REPEAT PRINT. DO REPEAT X = paterno_m1 paterno_m2. IF  (paterno_c2   ~=   X) paterno_diferentes=1. END REPEAT PRINT. IF  (paterno_m1   ~=   paterno_m2) paterno_diferentes=1.
EXECUTE.
Wich gave me what I want. I wonder if this could be done with fever lines of if there is a more eficient way to do this
 
Thank you very much

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

Re: Compare string variables

ANDRES ALBERTO BURGA LEON
 
Thank you, but I don't fully undertand what you mean.
 
Is something like:
 
IF (MIN(paterno_c1 paterno_c2 paterno_m1 paterno_m2) NE MAX(paterno_c1 paterno_c2 paterno_m1 paterno_m2)) paterno_diferentes=1.
EXECUTE.
 
This didn't work.
 
Andres



-----"SPSSX(r) Discussion" <[hidden email]> escribió: -----
Para: [hidden email]
De: David Marso
Enviado por: "SPSSX(r) Discussion"
Fecha: 30/01/2013 11:24
Asunto: Re: Compare string variables

IF (MIN(varlist) NE MAX(varlist)) .......
......


ANDRES ALBERTO BURGA LEON wrote

> Helo to everybody:
> &nbsp;
> I have four string variables (paterno_c1, paterno_c2 paterno_m1,
> paterno_2) and almost 200000 cases
> &nbsp;
> I want to compare if the content of any of the four variables&nbsp;is
> diferent.
> &nbsp;
> So far I've come with:
> &nbsp;
> DO REPEAT X = paterno_c2 paterno_m1 paterno_m2. IF&nbsp;
> (paterno_c1&nbsp;&nbsp; ~=&nbsp;&nbsp; X) paterno_diferentes=1. END REPEAT
> PRINT. DO REPEAT X = paterno_m1 paterno_m2. IF&nbsp;
> (paterno_c2&nbsp;&nbsp; ~=&nbsp;&nbsp; X) paterno_diferentes=1. END REPEAT
> PRINT. IF&nbsp; (paterno_m1&nbsp;&nbsp; ~=&nbsp;&nbsp; paterno_m2)
> paterno_diferentes=1.
> EXECUTE.
> Wich gave me what I want. I wonder if this could be done with fever lines
> of if there is a more eficient way to do this
> &nbsp;
> Thank you very much
>
> ====================To manage your subscription to SPSSX-L, send a message
> to

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Compare-string-variables-tp5717820p5717823.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Compare string variables

David Marso
Administrator
The elements in the lists must be comma separated.
If the min value is the same as the max value then all of the elements must be identical.
Conversely, If they are not equivalent then there must be a difference.
--
data list / a b c d (4a1).
begin data
abcd
aaaa
bbbb
abbb
end data.
COMPUTE diff=( MIN(a, b, c, d) NE MAX(a, b, c, d)).
LIST.


A B C D     DIFF

a b c d     1.00
a a a a      .00
b b b b      .00
a b b b     1.00


Number of cases read:  4    Number of cases listed:  4


ANDRES ALBERTO BURGA LEON wrote
 
Thank you, but I don't fully undertand what you mean.
 
Is something like:
 
IF (MIN(paterno_c1 paterno_c2 paterno_m1 paterno_m2) NE MAX(paterno_c1 paterno_c2 paterno_m1 paterno_m2)) paterno_diferentes=1. EXECUTE.
 
This didn't work.
 
Andres -----"SPSSX(r) Discussion" <[hidden email]> escribió: -----

Para: [hidden email] De: David Marso <[hidden email]> Enviado por: "SPSSX(r) Discussion" <[hidden email]> Fecha: 30/01/2013 11:24 Asunto: Re: Compare string variables IF (MIN(varlist) NE MAX(varlist)) ....... ...... ANDRES ALBERTO BURGA LEON wrote > Helo to everybody: > &nbsp; > I have four string variables (paterno_c1, paterno_c2 paterno_m1, > paterno_2) and almost 200000 cases > &nbsp; > I want to compare if the content of any of the four variables&nbsp;is > diferent. > &nbsp; > So far I've come with: > &nbsp; > DO REPEAT X = paterno_c2 paterno_m1 paterno_m2. IF&nbsp; > (paterno_c1&nbsp;&nbsp; ~=&nbsp;&nbsp; X) paterno_diferentes=1. END REPEAT > PRINT. DO REPEAT X = paterno_m1 paterno_m2. IF&nbsp; > (paterno_c2&nbsp;&nbsp; ~=&nbsp;&nbsp; X) paterno_diferentes=1. END REPEAT > PRINT. IF&nbsp; (paterno_m1&nbsp;&nbsp; ~=&nbsp;&nbsp; paterno_m2) > paterno_diferentes=1. > EXECUTE. > Wich gave me what I want. I wonder if this could be done with fever lines > of if there is a more eficient way to do this > &nbsp; > Thank you very much > > ====================To manage your subscription to SPSSX-L, send a message > to > LISTSERV@.UGA >  (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Compare-string-variables-tp5717820p5717823.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Compare string variables

Zdaniuk, Bozena-3
the easiest would be to copy the variables into two separate files and use COMPARE FILES feature which used to be available via DATA ENTRY package in SPSS. Does anyone know if SPSS still provides that package? It was a very buggy and clunky data entry program but that one COMPARE feature was VERY useful and well done.
bozena
________________________________________
From: SPSSX(r) Discussion [[hidden email]] on behalf of David Marso [[hidden email]]
Sent: Wednesday, January 30, 2013 10:07 AM
To: [hidden email]
Subject: Re: Compare string variables

The elements in the lists must be *comma *separated.
If the min value is the same as the max value then all of the elements must
be identical.
Conversely, If they are not equivalent then there must be a difference.
--
data list / a b c d (4a1).
begin data
abcd
aaaa
bbbb
abbb
end data.
COMPUTE diff=( MIN(a, b, c, d) NE MAX(a, b, c, d)).
LIST.


A B C D     DIFF

a b c d     1.00
a a a a      .00
b b b b      .00
a b b b     1.00


Number of cases read:  4    Number of cases listed:  4



ANDRES ALBERTO BURGA LEON wrote

> &nbsp;
> Thank you, but I don't fully undertand what you mean.
> &nbsp;
> Is something like:
> &nbsp;
> IF (MIN(paterno_c1 paterno_c2 paterno_m1 paterno_m2) NE MAX(paterno_c1
> paterno_c2 paterno_m1 paterno_m2)) paterno_diferentes=1. EXECUTE.
> &nbsp;
> This didn't work.
> &nbsp;
> Andres -----"SPSSX(r) Discussion" &lt;

> SPSSX-L@.UGA

> &gt; escribió: -----
>
> Para:

> SPSSX-L@.UGA

>  De: David Marso &lt;

> DAVID.MARSO@

> &gt; Enviado por: "SPSSX(r) Discussion" &lt;

> SPSSX-L@.UGA

> &gt; Fecha: 30/01/2013 11:24 Asunto: Re: Compare string variables IF
> (MIN(varlist) NE MAX(varlist)) ....... ...... ANDRES ALBERTO BURGA LEON
> wrote &gt; Helo to everybody: &gt; &amp;nbsp; &gt; I have four string
> variables (paterno_c1, paterno_c2 paterno_m1, &gt; paterno_2) and almost
> 200000 cases &gt; &amp;nbsp; &gt; I want to compare if the content of any
> of the four variables&amp;nbsp;is &gt; diferent. &gt; &amp;nbsp; &gt; So
> far I've come with: &gt; &amp;nbsp; &gt; DO REPEAT X = paterno_c2
> paterno_m1 paterno_m2. IF&amp;nbsp; &gt; (paterno_c1&amp;nbsp;&amp;nbsp;
> ~=&amp;nbsp;&amp;nbsp; X) paterno_diferentes=1. END REPEAT &gt; PRINT. DO
> REPEAT X = paterno_m1 paterno_m2. IF&amp;nbsp; &gt;
> (paterno_c2&amp;nbsp;&amp;nbsp; ~=&amp;nbsp;&amp;nbsp; X)
> paterno_diferentes=1. END REPEAT &gt; PRINT. IF&amp;nbsp;
> (paterno_m1&amp;nbsp;&amp;nbsp; ~=&amp;nbsp;&amp;nbsp; paterno_m2) &gt;
> paterno_diferentes=1. &gt; EXECUTE. &gt; Wich gave me what I want. I
> wonder if this could be done with fever lines &gt; of if there is a more
> eficient way to do this &gt; &amp;nbsp; &gt; Thank you very much &gt; &gt;
> ====================To manage your subscription to SPSSX-L, send a message
> &gt; to &gt; LISTSERV@.UGA &gt; &nbsp;(not to SPSSX-L), with no body text
> except the &gt; command. To leave the list, send the command &gt; SIGNOFF
> SPSSX-L &gt; For a list of commands to manage subscriptions, send the
> command &gt; INFO REFCARD ----- Please reply to the list and not to my
> personal email. Those desiring my consulting or training services please
> feel free to email me. -- View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Compare-string-variables-tp5717820p5717823.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> ===================== To manage your subscription to SPSSX-L, send a
> message to

> LISTSERV@.UGA

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

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Compare-string-variables-tp5717820p5717827.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Compare string variables

ANDRES ALBERTO BURGA LEON
In reply to this post by David Marso
Thank you David, this worked just fine
 
Kindly Andres



-----"SPSSX(r) Discussion" <[hidden email]> escribió: -----
Para: [hidden email]
De: David Marso
Enviado por: "SPSSX(r) Discussion"
Fecha: 30/01/2013 13:06
Asunto: Re: Compare string variables

The elements in the lists must be *comma *separated.
If the min value is the same as the max value then all of the elements must
be identical.
Conversely, If they are not equivalent then there must be a difference.
--
data list / a b c d (4a1).
begin data
abcd
aaaa
bbbb
abbb
end data.
COMPUTE diff=( MIN(a, b, c, d) NE MAX(a, b, c, d)).
LIST.


A B C D     DIFF

a b c d     1.00
a a a a      .00
b b b b      .00
a b b b     1.00


Number of cases read:  4    Number of cases listed:  4



ANDRES ALBERTO BURGA LEON wrote

> &nbsp;
> Thank you, but I don't fully undertand what you mean.
> &nbsp;
> Is something like:
> &nbsp;
> IF (MIN(paterno_c1 paterno_c2 paterno_m1 paterno_m2) NE MAX(paterno_c1
> paterno_c2 paterno_m1 paterno_m2)) paterno_diferentes=1. EXECUTE.
> &nbsp;
> This didn't work.
> &nbsp;
> Andres -----"SPSSX(r) Discussion" &lt;

> SPSSX-L@.UGA

> &gt; escribió: -----
>
> Para:

> SPSSX-L@.UGA

>  De: David Marso &lt;

> DAVID.MARSO@

> &gt; Enviado por: "SPSSX(r) Discussion" &lt;

> SPSSX-L@.UGA

> &gt; Fecha: 30/01/2013 11:24 Asunto: Re: Compare string variables IF
> (MIN(varlist) NE MAX(varlist)) ....... ...... ANDRES ALBERTO BURGA LEON
> wrote &gt; Helo to everybody: &gt; &amp;nbsp; &gt; I have four string
> variables (paterno_c1, paterno_c2 paterno_m1, &gt; paterno_2) and almost
> 200000 cases &gt; &amp;nbsp; &gt; I want to compare if the content of any
> of the four variables&amp;nbsp;is &gt; diferent. &gt; &amp;nbsp; &gt; So
> far I've come with: &gt; &amp;nbsp; &gt; DO REPEAT X = paterno_c2
> paterno_m1 paterno_m2. IF&amp;nbsp; &gt; (paterno_c1&amp;nbsp;&amp;nbsp;
> ~=&amp;nbsp;&amp;nbsp; X) paterno_diferentes=1. END REPEAT &gt; PRINT. DO
> REPEAT X = paterno_m1 paterno_m2. IF&amp;nbsp; &gt;
> (paterno_c2&amp;nbsp;&amp;nbsp; ~=&amp;nbsp;&amp;nbsp; X)
> paterno_diferentes=1. END REPEAT &gt; PRINT. IF&amp;nbsp;
> (paterno_m1&amp;nbsp;&amp;nbsp; ~=&amp;nbsp;&amp;nbsp; paterno_m2) &gt;
> paterno_diferentes=1. &gt; EXECUTE. &gt; Wich gave me what I want. I
> wonder if this could be done with fever lines &gt; of if there is a more
> eficient way to do this &gt; &amp;nbsp; &gt; Thank you very much &gt; &gt;
> ====================To manage your subscription to SPSSX-L, send a message
> &gt; to &gt; LISTSERV@.UGA &gt; &nbsp;(not to SPSSX-L), with no body text
> except the &gt; command. To leave the list, send the command &gt; SIGNOFF
> SPSSX-L &gt; For a list of commands to manage subscriptions, send the
> command &gt; INFO REFCARD ----- Please reply to the list and not to my
> personal email. Those desiring my consulting or training services please
> feel free to email me. -- View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Compare-string-variables-tp5717820p5717823.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> ===================== To manage your subscription to SPSSX-L, send a
> message to

> LISTSERV@.UGA

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

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Compare-string-variables-tp5717820p5717827.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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