This example concatenates the string and numeric variables, inserting an underscore between the two values:
data list list /id (a19) portsize(f3).
begin data
A123456789012345678 1
B123456789012345678 12
C123456789012345678 123
end data.
string newid (a23).
compute newid=concat(rtrim(id), "_", string(portsize, n3)).
list.
If you don't want the leading zeroes in the portsize portion of the new string variable, change n3 to f3 in the Compute command.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:
[hidden email]] On Behalf Of jimjohn
Sent: Wednesday, September 10, 2008 9:25 AM
To:
[hidden email]
Subject: Concatenate strings
can someone plz tell me waht function to use to concatenate two strings. For
example, I have the following two variables: ID which is a string (width
19). Then, I have PortSize, whihc is a numerical (width 3). The PortSize can
usually have between 1 and 3 digits. Now, my ID is supposed to be a unique
ID, but I'm noticing that sometimes two investments have the same ID. So,
what I want to do is concatenate PortSize with ID. I tried converting
PortSize to string and then using the concat function but I still get a type
mismatch error. Any idea how to do this? Thanks!
--
View this message in context:
http://www.nabble.com/Concatenate-strings-tp19414582p19414582.htmlSent 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