LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2004)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 Apr 2004 16:10:40 -0400
Reply-To:     Doug Fuller <ao5631@wayne.edu>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Doug Fuller <ao5631@wayne.edu>
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 >sites.

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 line. -- Doug Fuller dfuller@wayne.edu Research Technician, Wayne State University Department of Psychiatry and Behavioral Neurosciences


Back to: Top of message | Previous page | Main SPSSX-L page