SAS Values

Reply
Regular Contributor
Posts: 212

SAS Values

Hi, again.

I have a doubt.

Is there any way to recover numeric values like:

2.45 is formatted as comma10.2, but it's damaged, because this value comes like this 2.446,58 as string.

So the value of 2.45 is after i format the variable, but i need then like 2.446,58.

Is there any way to recover it ?

Tks,

Rodrigo Elias

Regular Contributor
Posts: 212

Re: SAS Values

But there are a lot more data like this.

I need to recover the table.

Tks

Super User
Super User
Posts: 6,372

Re: SAS Values

How did you try to convert the string to a number?

You can use the COMMA informat to read numbers in the normal format for your LOCALE setting.

Use COMMAX informat to read those where the roles of the comma and the period have been reversed.

38   data sample;

39     input str $20. ;

40     num1 = input(str,comma20.);

41     num2 = input(str,commaX20.);

42     put (_all_) (=);

43   cards;

str=1,234.56 num1=1234.56 num2=1.23456

str=1.234,56 num1=1.23456 num2=1234.56

Super User
Super User
Posts: 6,372

Re: SAS Values

Do you already have the values as numbers and no longer have the strings?

Print the number without a format (or using the BEST format).

You might just need to multiple by 1000 for that example.

But if the original number was less than 100 and it had 2 decimal places you would need to divide by 100.

If the original value was greater than a million then you probably have a missing numeric value.

Ask a Question
Discussion stats
  • 3 replies
  • 164 views
  • 0 likes
  • 2 in conversation