Data concatenation in SPSS -
I have two data columns in SPSS
hhid = 1 2 3 carid = 26 27 28 I want to create a new column which connects both Hahid and Karjid and gives me output
newid = 1_26 2_27 3_28 I'm new to SPSS, I appreciate your help.
The following code assumes that your IDs are variable numerals otherwise the COMPUTE command Delete the STRING function from * Generates a string variable of 17 characters. Adjust the length as you wish STRING Nude (A17) COMPUTE Newid = CONCAT (LTRIM (STRING (Hahid, F8)), "_", LTRIM (STRING (Carid, F8)). Executed. Explanation: STRING (var, format) function converts the numeric value of "var" to the string of the given format. The code above the format has an 8 digit number without any decimal. The output of these functions is an 8-character string, which is the main spacing. To delete the main spaces, this function is wrapped in the LTRIM (string) function.
Comments
Post a Comment