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 (March 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 14 Mar 2003 08:30:26 -0800
Reply-To:     Max <mjohnson@HSAG.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Max <mjohnson@HSAG.COM>
Organization: http://groups.google.com/
Subject:      Re: length(compress('')) is 1 ?
Content-Type: text/plain; charset=ISO-8859-1

Sig, This should do what you want.

data _null_; string='9'; if compress(string,'0987654321')=' ' then do; number_of_digits = 1 + length(string) - length(compress(string,'0987654321')); end; if compress(string,'0987654321') ne ' ' then do; number_of_digits = length(string) - length(compress(string,'0987654321')); end; put number_of_digits; run;

HTH, MAX

stigeide@yahoo.com (Stig Eide) wrote in message news:<faa59d77.0303140054.4ccbfbb8@posting.google.com>... > I don't get this. > Why is length(compress('')) 1? > I am trying to count number of digits in a text string, > what I came up with was: > number_of_digits = length(string) - length(compress(string,'0987654321')); > > But this don't work because the length of compress('9','9') is 1... > > Anyone have a better idea on how to count number of digits? > > Thanks! > Stig


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