Date: Wed, 16 Feb 2011 22:07:46 -0500
Reply-To: Nat Wooding <nathani@VERIZON.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <nathani@VERIZON.NET>
Subject: Re: Counting digits
Content-Type: text/plain; charset="US-ASCII"
The following seems to work ok.
input y ;
numbers = ceil( log10( y + .1 ) );
format y comma15.;
* the addition of the .1 was needed to get the 10000000 to work;
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Lorne
Sent: Wednesday, February 16, 2011 6:47 PM
Subject: Counting digits
Simple question: I want to get the number of digits to the left of the
decimal place from a value in a numeric variable (excluding negative sign
if there is one).
I can live with the following which works but I'm wondering if it can be
even simpler than this? I thought there might be a numeric function to do
it directly but couldn't find one.
y = 76877.234;
result = countc(put(int(y),32.),,"d");
result = length(compress(put(int(y),32.)," -"));