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 (June 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 17 Jun 2011 16:17:29 -0400
Reply-To:     Dawn Wiest <>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Dawn Wiest <>
Subject:      Re: String variable -  leading zeros
Comments: To: Gene Maguin <>
In-Reply-To:  <>
Content-Type: multipart/alternative;

Gene, you are correct: the variable was imported as a numeric variable. I applied the syntax ViAnn recommended and it worked beautifully. Thanks!

>>> Gene Maguin <> 6/17/2011 3:58 PM >>> Dawn,

Are you sure that ID remains a string variable once imported? The behavior you describe seems consistent with the import of a numeric variable or a string variable being converted to numeric in the import process.

Gene Maguin

If you need the leading zeroes than you must be doing a string compare since 12 and 012 are the same number. So you need to convert the number back to a string using the string function and specifying the N format for the number. string stringvar(a9). compute stringvar=string(numbervar, n9). From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Dawn Wiest Sent: Friday, June 17, 2011 3:38 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: String variable - leading zeros

Hello – After importing data from a different program into SPSS, the leading zeros on a string variable that I use as a key variable across multiple data sets are lost. I need to recapture those leading zeros. This is an ID variable that should have nine digits. When the data are exported, only the non-zero digits remain so that, for example, ID 000022122 becomes 22122; ID 000000011 becomes 11; ID 077777777 becomes 77777777, and so on. Is there a way to replenish the leading zeros on this variable so that the total length of each of the resulting values is 9 digits? Thank you in advance for your help Dawn

Dawn Wiest, Ph.D. Senior Research Analyst Research Center - 7th Floor American College of Physicians 190 North Independence Mall West Philadelphia, PA 19106-1572 (215) 351-2561


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