From: Raj on
Hi,

I have 10 length charecter column which has numeric also.

for exmaple:

LT100124
009552319924

my requirement is if the value has only 0-9 like 009552319924 then i
need to write to output file and convert to numeric else leave them.

could you please help me how to do that.

Regards,
raj
From: nina on
data _null_;
input _str_ $20. ;
new_str_ = compress(_str_,,'kd');
put(_all_)(/=);
datalines;
LT100124
009552319924
;;;;
run;
From: Arthur Tabachneck on
Raj,

If I understand your question correctly then you might be able to use
something like:

data have;
input old $20.;
cards;
LT100124
009552319924
;

data want;
set have;
if length(old) eq length(compress(old,,'kd')) then
new=input(old,best12.);
run;

HTH,
Art
---------
On Apr 27, 5:47 am, Raj <rajiv...(a)gmail.com> wrote:
> Hi,
>
> I have 10 length charecter column which has numeric also.
>
> for exmaple:
>
> LT100124
> 009552319924
>
> my requirement is if the value has only 0-9 like 009552319924 then i
> need to write to output file and convert to numeric else leave them.
>
> could you please help me how to do that.
>
> Regards,
> raj

From: Nat Wooding on
As I read the post, Raj wants one file with the numbers and the other with
the strings. For fun, I found a different way to test whether there were
characters in the original variable.

Nat Wooding
data have;

input old $20.;

cards;

LT100124

009552319924

;

Data Char (drop = num ) Numeric;

set have;

if upcase( old ) ne Lowcase ( old) then do;

* we have characters in the string;

output char;

return;

end;

Num = input( old , best. );

output numeric;

run;


----- Original Message -----
From: "Arthur Tabachneck" <art297(a)NETSCAPE.NET>
To: <SAS-L(a)LISTSERV.UGA.EDU>
Sent: Tuesday, April 27, 2010 9:47 AM
Subject: Re: Finding numbers in Charecter


> Raj,
>
> If I understand your question correctly then you might be able to use
> something like:
>
> data have;
> input old $20.;
> cards;
> LT100124
> 009552319924
> ;
>
> data want;
> set have;
> if length(old) eq length(compress(old,,'kd')) then
> new=input(old,best12.);
> run;
>
> HTH,
> Art
> ---------
> On Apr 27, 5:47 am, Raj <rajiv...(a)gmail.com> wrote:
>> Hi,
>>
>> I have 10 length charecter column which has numeric also.
>>
>> for exmaple:
>>
>> LT100124
>> 009552319924
>>
>> my requirement is if the value has only 0-9 like 009552319924 then i
>> need to write to output file and convert to numeric else leave them.
>>
>> could you please help me how to do that.
>>
>> Regards,
>> raj

From: Steve James on
On Apr 27, 5:47 am, Raj <rajiv...(a)gmail.com> wrote:
> Hi,
>
> I have 10 length charecter column which has numeric also.
>
> for exmaple:
>
> LT100124
> 009552319924
>
> my requirement is if the value has only 0-9 like 009552319924 then i
> need to write to output file and convert to numeric else leave them.
>
> could you please help me how to do that.
>
> Regards,
> raj

Use the ANYALPHA function.

if anyalpha(string) ne 0 then put "string has characters' ; else put
'string has no characters' ;

steve