Date: Fri, 16 Sep 2005 15:30:30 +0000
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: pre-pending zeros
Assuming for SD2 you meant 3SD, and no internal blanks, try
data w ;
length y $ 3 ;
input x $char6. ;
y = translate(reverse(substr(reverse(trim(x)),1,3)),"0"," ") ;
Date: Fri, 16 Sep 2005 07:46:29 -0700
Sender: "SAS(r) Discussion"
Subject: pre-pending zeros
Comments: To: sas-l
Content-Type: text/plain; charset="iso-8859-1"
I got stuck in a situation.
There is a variable defined as character and the length of that
variable is 6.
Now I want to take the last 3 character only and for that I can use the
but if the variable length is less than 3 then pre pend that with the
so the output should look like this.
When I tried then I messed up at the numeric to character things and
preprnding zero don't work.
Thank you in the advance