Date: Wed, 12 May 2004 07:09:22 -0700
Reply-To: Barry Debenham <barry.debenham@TALK21.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Barry Debenham <barry.debenham@TALK21.COM>
Subject: Re: aligning and length statement
Content-Type: text/plain; charset=ISO-8859-1
ghellrieg@T-ONLINE.DE (Gerhard Hellriegel) wrote in message news:<200405120916.i4C9GEG25063@listserv.cc.uga.edu>...
> On Wed, 12 May 2004 05:08:52 -0400, Gerhard Hellriegel
> <ghellrieg@T-ONLINE.DE> wrote:
> >On Wed, 12 May 2004 02:27:52 GMT, David Wright <David_wright@SPRA.COM> wrote:
> >>I was helping a client who needed to right align and zero fill a character
> >>field (y).
> >>I suggested:
> >>length $20 x;
> >>and then translate the blanks to zeros.
> >>This turns out to only work if there is no length statement.
> >>Why is this the case? Doesn't the length statement simply intitalize a
> >>variable? And how can I work around the possiblity x might inititalize with a
> >>length that is too small?
> >Last thing I don't understand: what means "initialize with a length that is
> >too small"? Why you do not use a length which is long enough? Use length x
> >$9000, if that is too short, use 20000 (???)
> >What is the problem? To get a numeric field with leadfing 0's into a string?
> >Maybe that could be useful:
> >proc format;
> > picture zzz low-high = "9999999999999999";
> >data test;
> > x=1234;
> > y=put(x,zzz.);
> > put y=;
> >however there is a length limit of 16 for that solution. Another way of
> >getting ist to work:
> >data test;
> > length x $333;
> > y="abc";
> > x=reverse(y);
> > x=reverse(translate(x,"0"," "));
> > put x=;
> >That is not limited to numerics and nearly not limited in length (somewhere
> >at 32000)
> By the way: if it is a numeric, you can also use the z-format:
> 91 data test;
> 92 x=1234;
> 93 y=put(x,z30.);
> 94 put y=;
> 95 run;
If the statement you've entered above does not contain a typo then
your length statement needs correcting.
length $20 x;
length x $20;
I hope it's this simple for you.