combining variable values

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

combining variable values

Jill Adelson-2
We have three variables that we need to combine into a unique code.  We have a secondary data set that, unfortunately, does not have a unique identifier for our subjects.  There is a unique country code, a unique school code within each country (but schools in different countries can have the same code), and a unique classroom code within each school (but classrooms in different schools/countries can have the same classroom code).  We have not been able to figure out the syntax to combine the three codes into one unique code.  For example, if the subject was in country 23, school 14, and classroom 10, we want a new variable that would be the ID and be 231410.  Any help creating the variable would be very much appreciated!

Sincerely,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville

Reply | Threaded
Open this post in threaded view
|

Re: combining variable values

Bruce Weaver
Administrator
Assuming none of the country, school, or classroom codes are more than 2 digits:

compute ID = country*10000 + school*100 + classroom.


Jill Adelson-2 wrote
We have three variables that we need to combine into a unique code.  We have
a secondary data set that, unfortunately, does not have a unique identifier
for our subjects.  There is a unique country code, a unique school code
within each country (but schools in different countries can have the same
code), and a unique classroom code within each school (but classrooms in
different schools/countries can have the same classroom code).  We have not
been able to figure out the syntax to combine the three codes into one
unique code.  For example, if the subject was in country 23, school 14, and
classroom 10, we want a new variable that would be the ID and be 231410.
Any help creating the variable would be very much appreciated!

Sincerely,
Jill

--
Jill L. Adelson, Ph.D.
Assistant Professor
Educational Psychology, Measurement, and Evaluation Program
Educational and Counseling Psychology Department
College of Education and Human Development
University of Louisville
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: combining variable values

Junelyn Peeples
Hi Jill,

You can concatenate the variables.  SPSS has its own concatenate function.  They might all need to be stored as string values to use it.  Easy enough to convert them.

STRING session_id (A6).
COMPUTE session_id = CONCAT(country, school, classroom) .
EXECUTE .


Good luck,
Junelyn

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Junelyn Pangan Peeples
Director, Institutional Research
Office of Undergraduate Education
http://irue.ucr.edu/

University of California, Riverside
900 University Ave
321 Surge Suite H
Riverside, CA 92521

Office: 951-827-2661
Fax: 951-827-7745
Email: [hidden email]

Nothing in life just happens.  You have to have the stamina to meet the obstacles and overcome them.
~Golda Meir~


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Wednesday, November 17, 2010 12:21 PM
To: [hidden email]
Subject: Re: combining variable values

Assuming none of the country, school, or classroom codes are more than 2
digits:

compute ID = country*10000 + school*100 + classroom.



Jill Adelson-2 wrote:

>
> We have three variables that we need to combine into a unique code.  We
> have
> a secondary data set that, unfortunately, does not have a unique
> identifier
> for our subjects.  There is a unique country code, a unique school code
> within each country (but schools in different countries can have the same
> code), and a unique classroom code within each school (but classrooms in
> different schools/countries can have the same classroom code).  We have
> not
> been able to figure out the syntax to combine the three codes into one
> unique code.  For example, if the subject was in country 23, school 14,
> and
> classroom 10, we want a new variable that would be the ID and be 231410.
> Any help creating the variable would be very much appreciated!
>
> Sincerely,
> Jill
>
> --
> Jill L. Adelson, Ph.D.
> Assistant Professor
> Educational Psychology, Measurement, and Evaluation Program
> Educational and Counseling Psychology Department
> College of Education and Human Development
> University of Louisville
>
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/combining-variable-values-tp3269692p3269705.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: combining variable values

Richard Ristow
In reply to this post by Jill Adelson-2
At 02:54 PM 11/17/2010, Jill Adelson wrote:

>We have three variables that we need to combine into a unique
>code.  We have a secondary data set that, unfortunately, does not
>have a unique identifier for our subjects.  There is a unique
>country code, a unique school code within each country (but schools
>in different countries can have the same code), and a unique
>classroom code within each school (but classrooms in different
>schools/countries can have the same classroom code).  We have not
>been able to figure out the syntax to combine the three codes into
>one unique code.

Bruce Weaver's suggestion should work, and there are variations that
would work as well.

But you may not need to do it. SPSS commands that take case
identifiers (including ADD FILES, MATCH FILES, AGGREGATE) work fine
with a set of variables as the identifier. Unless there's a specific
reason you need a one-variable identifier, you could just use the set
of three: COUNTRY, SCHOOL, CLASSROOM.

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