Close Home Forum Sign up / Log in

SPSS Query: combining variables

P

Hi guys

I'm trying to figure out if there is an easy way of combining my variables to create a new one, rather than doing it all manually. I have 3 variables (first two letters of mothers maiden name, day of birth, and last two digits of phone number) for each participant. Put together, I want to produce a unique 6-digit code for each participant. Does anyone know how this is possible? I'm wondering if it's in 'commute variables' but can't find anything suitable?

Purpleflower x

F

======= Date Modified 26 Mar 2012 14:16:51 =======
======= Date Modified 26 Mar 2012 14:15:37 =======
I'm not sure if there's a way you can do it in SPSS... but there certainly is in Excel, using the CONCATENATE function (http://spreadsheets.about.com/od/excelfunctions/qt/07-concatenate.htm)

I normally arrange all my data in Excel precisely how i want it in SPSS and then open the .xls file through SPSS (if that makes sense) as i tend to find SPSS doesn't do most of the things i want. Also, doing it this way, SPSS won't override the data in your .xls file so you can always reopen your original dataset if SPSS has a paddy (which i find it does sometimes).

Afraid i don't know what commute variables means... However, a quick google finds this: http://www.slideshare.net/ay17071951/using-spss-tranform-variable-compute-presentation which might help you do it within SPSS itself.... but i'm not sure. I think it takes "compute" to mean "do computations on" rather than just a simple text transform.

C

I can't think of a way in SPSS but if you copy and paste into Excel it can be done there and then copied back. This link shows how it works, but basically if you have "name" in cell A1 "day" in cell A2 and "digit" in cell A3 to combine them you'd type =A1&A2&A3 into cell A4.


http://www.youtube.com/watch?v=P6NDbViRQW4

P

Thank you, I really appreciate that :)

C

There is also a concatenate function in SPSS (now what I know what it's called I could google it!) I just tried to make it work and it came up with errors that I don't understand. But if you look it up it may work for you.

P

I used Excel in the end, but CaitlinBond's right, it can be done in SPSS also. If anyone needs to do this in the future here it is:

If your three variables are string variables ... then they can be concatenated to a six digit string variable using the concat function i.e. Transform >>> Calculator >>> then it would be Concat(variable1, variable 2, variable 3) ... concatenation will only work with string variables ... =Concatenation() in Excel should work with either string/text variables or with numeric/scale variables.

Cheers guys :-)

Q

======= Date Modified 28 Mar 2012 09:09:26 =======
============= Edited by a Moderator =============
*Removed by moderators - spam*

21983