Tips – Concatenation of 2 string variables
I met a SPSS user last week that worked with very big numbers and wanted to add 2 together as a key variable.
You will get problem if the variable you work with has a format bigger than 17 numbers that was the case here, so in that case I recommended the user to use the string format and the CONCAT command from COMPUTE.
First you must change the type from “Numeric” to “String”, in the “Variable View”.
Then it looks like this in the data editor window:
Then it’s time to add these 2 variable together into one.
The command is found in : Transform – compute
To get more information how to use the command you click on “string” and then “concat”.
Here is the dialog box:
Then click on the Arrow (see the red circle) so the function jumps up to the formula box.
Also write a name of the new variable here “var1var2”.
Then don’t forget to click on the button “Type & Label” (otherwise you will get an error message), where you change the format of the new variable to string with 21 characters (17+4).
Finally click “Continue” and “OK”.
Here is the new variable “var1var2”.
So if working with big formats like this, use string format.
Greetings Gunilla Rudander