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 (September 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 16 Sep 2005 08:10:30 -0700
Reply-To:     Toby <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Toby <tobydunn@HOTMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: pre-pending zeros
Comments: To: sas-l@uga.edu
In-Reply-To:  <1126881989.004148.76310@g44g2000cwa.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"

VD,

Try:

data one ; infile cards ; input x $6. ; cards ; 123456 23SD 000001 100000 22SSS1 13 ; run ;

data two ; set one ; y = translate(substr(right(x),4,3),'0',' ') ; run ;

proc print ; run ;

Toby Dunn

Hi all

I got stuck in a situation. There is a variable defined as character and the length of that variable is 6. Example: PAT 123456 23SD 000001 100000 22SSS1 13 Now I want to take the last 3 character only and for that I can use the

substr. but if the variable length is less than 3 then pre pend that with the zeros. so the output should look like this.

PAT 456 SD2 001 000 SS1 013

When I tried then I messed up at the numeric to character things and preprnding zero don't work.

Thank you in the advance


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