BookmarkSubscribeRSS Feed
DartRodrigo
Lapis Lazuli | Level 10

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

3 REPLIES 3
DartRodrigo
Lapis Lazuli | Level 10

But there are a lot more data like this.

I need to recover the table.

Tks

Tom
Super User Tom
Super User

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

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 429 views
  • 0 likes
  • 2 in conversation