Date: Tue, 20 Apr 2004 16:10:40 -0400
Reply-To: Doug Fuller <email@example.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Doug Fuller <firstname.lastname@example.org>
Subject: Re: Joining two numeric variables
Content-Type: text/plain; charset=us-ascii
>I want to join (concatenate) the values of two numeric
>variables into a new variable. One variable is a four
>digit coalition site number and the other is a student id
>number. By joining the two variables I will be able to
>create a set of unique id numbers across several coalition
I've noticed a lot of replies involve changing formats from
numeric to string then back to numeric. Is there any reason
something like this wouldn't work? (Assumes the longest
student ID is 6 digits long)
*Basically, shift site_id by 6 digits and add stdnt_id.
compute new_id = (site_id * 1000000) + stdnt_id.
*Then, if you require leading zeroes.
formats new_id (n10).
This syntax works for me in V9. Adjust the 1000000 and
formats line, suit to taste.
It's quick, dirty, and not terribly flexible, but if you
have a constant maximum length for the student ID, it will
preserve leading zeroes for it; leading zeroes in the
site_id, if necessary, are handled by the additional formats
Research Technician, Wayne State University
Department of Psychiatry and Behavioral Neurosciences