Matching string variables

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

Matching string variables

Paul Frankel
Friends,

We have two separate Excel files that I will read into SPSS as two
separate data files.  The two files have one variable in common:
Employee_Name as a string variable.  I have had trouble matching the
data files because in one file Employee_Name might be written as 'PAUL'
and in the other it might be written as 'Paul.'  In other words, how can
I tell SPSS to *not* be case sensitive about values of a keyed variable?

Many thanks in advance for your help!

Paul Frankel, Ph.D.
Research Associate
Children's Division
American Humane Association
63 Inverness Drive East
Englewood, Colorado 80112
Ph.   303-925-9429
Dash 720-472-2165
Fax   303-858-0871
[hidden email]
 
www.americanhumane.org  
Protecting Children & Animals Since 1877

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

Marta Garcia-Granero
Paul Frankel wrote:
> We have two separate Excel files that I will read into SPSS as two
> separate data files.  The two files have one variable in common:
> Employee_Name as a string variable.  I have had trouble matching the
> data files because in one file Employee_Name might be written as 'PAUL'
> and in the other it might be written as 'Paul.'  In other words, how can
> I tell SPSS to *not* be case sensitive about values of a keyed variable?
>
You can capitalize all names in both files before matching:

Import 1st Excel file.
COMPUTE Employee_Name=UPCASE(Employee_Name).

Import 2nd excel file.
COMPUTE Employee_Name=UPCASE(Employee_Name).

MATCH both files by Employee_Name.

HTH,
Marta GarcĂ­a-Granero

--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

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

Art Kendall
In reply to this post by Paul Frankel
If all you have is a problem of case consistency then in each file,
create a new ID forced to upper case.
string newID (a12).
compute newID = upcase(oldid).

Do you have more than 1 case in a file  that has a name indicating the
same person? Did you mean to include the period inside the single
quotes?  if things like that happen you can get closer by trying
something like this untested syntax in each file
autorecode variables = newID /into numID.
*recode variations on a name into a single value (e.g., "PAUL" "PAUL."
AND "PAUL,"  would be recoded in the code for "PAUL".
recode numID (13,14,22 = 14) (81,82 = 81) (else = copy) into numID2.
*since the variations on a name might be different in the two files
create a matchID that is the value label from numID.
string matchID (a12).
compute matchID= valuelabel(numID).

when you do the match be sure to use the /IN specification

If you have more complex variations, please post examples of the other
kinds of variations.

Art Kendall
Social Research Consultants

Paul Frankel wrote:

> Friends,
>
> We have two separate Excel files that I will read into SPSS as two
> separate data files.  The two files have one variable in common:
> Employee_Name as a string variable.  I have had trouble matching the
> data files because in one file Employee_Name might be written as 'PAUL'
> and in the other it might be written as 'Paul.'  In other words, how can
> I tell SPSS to *not* be case sensitive about values of a keyed variable?
>
> Many thanks in advance for your help!
>
> Paul Frankel, Ph.D.
> Research Associate
> Children's Division
> American Humane Association
> 63 Inverness Drive East
> Englewood, Colorado 80112
> Ph.   303-925-9429
> Dash 720-472-2165
> Fax   303-858-0871
> [hidden email]
>
> www.americanhumane.org
> Protecting Children & Animals Since 1877
>
> ===================
> 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
Art Kendall
Social Research Consultants