Date: Thu, 13 Jun 2002 11:33:21 -0300
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Hector Maletta <firstname.lastname@example.org>
Subject: Re: concatenating variables to create a new variable
Content-Type: text/plain; charset=us-ascii
it looks you may simply multiply the numeric parts by powers of ten,
then add up, then convert to string again if you wish (you may just as
well stay numeric). Example:
Original ID: '0123', '1234'
Converted to numeric and partitioned into X=1, Y=23 for the first case,
and X=12 and Y=34 for the second.
Results: first case is NUMID=123, second case is NUMID=1234,
corresponding to the strings '0123' and '1234' in the original string
You can use NUMID directly, but just in case you want to go back to
string, you may directly convert to string (with RECODE NUMID
(convert)INTO Z), and then define your STRINGID inthe following:
STRINGID=Z for all cases with numeric values of 1000 or more, and
STRINGID=concatenation of '0' and Z for all values below 1000.
Hope this helps.
Universidad del Salvador
Buenos Aires, Argentina
Patricia Cleland wrote:
> Dear Listers,
> I have received a data set in which the unique case identifier has been broken down into its constituent parts and the identifier itself dropped from the data set . The problem is that the constituents of the id have been converted from string to numeric format. If the variables were all string, I would simply compute the id by concatenating the values. Unfortunately, in converting the variable to numeric the leading '0' has disappeared, that is I have 1, 2 ,3 rather than 01, 02, and 03. I tried converting the variables back to string and recoding '1' to '01' but I still don't have the leading 0. The variable has legitimate values greater than 9 so I can't simply force a 0 in front of all values. Does anyone have any suggestions?