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 (February 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 20 Feb 2005 14:22:09 -0500
Reply-To:     Nathaniel_Wooding@DOM.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <Nathaniel_Wooding@DOM.COM>
Subject:      Re: Convert ZIP into character and add missing zeroes infront
Content-type: text/plain; charset=US-ASCII

I suggest the use of the Z format which adds leading zeros to numbers.

Nat Wooding

data ; input zip @@; czip=put(zip,z5.); put zip= czip=; cards; 1234 12345 12045 run;

|---------+----------------------------> | | "Chang, Ei-Wen" | | | <Ei-Wen_Chang@CTB| | | .COM> | | | Sent by: "SAS(r) | | | Discussion" | | | <SAS-L@LISTSERV.U| | | GA.EDU> | | | | | | | | | 02/18/2005 07:57 | | | PM | | | Please respond to| | | "Chang, Ei-Wen" | | | | |---------+----------------------------> >------------------------------------------------------------------------------------------------------------------------------| | | | To: SAS-L@LISTSERV.UGA.EDU | | cc: | | Subject: Re: Convert ZIP into character and add missing zeroes infront | >------------------------------------------------------------------------------------------------------------------------------|

Try this.

length nzip $5 zip 5; nzip=translate( put(zip,$5.),'0',' ');

Ei-Wen

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nick . Sent: Monday, February 14, 2005 12:58 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Convert ZIP into character and add missing zeroes infront

Hello SAS experts,

I have ZIP codes in numeric form like 7001 (it's missing a zero infront to make it a legitimate 5-digit zip code), 60073(has 5- digits, it's fine), 1, etc. I would like to convert my numeric ZIPS into characters and at the same time add leading zeroes to make them legitimate 5-digits ZIPs. How do I do that? Thnaks much.

ZIP 7001 1 23 345

I would like ZIP to become a character variable like

ZIP 07001 00001 00023 00345

-- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm


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