BookmarkSubscribeRSS Feed
radha1
Calcite | Level 5

Hi,

 

Can anyone help me converting from 125,804 to 125804.

2.53.476
253476

 

Thanks in advance

2 REPLIES 2
Tom
Super User Tom
Super User

How is that a FORMAT issue?

Where are the existing values? Where do you want the converted values?

Do they have commas or periods in them? Or both?

 

If you have character variables why not just use COMPRESS()?

data have ;
  input str $20. ;
cards;
125,804 
2.53.476
253476
;

data want ;
 set have ;
 new = compress(str,',.');
run;
Obs      str        new

 1     125,804     125804
 2     2.53.476    253476
 3     253476      253476
ballardw
Super User

At least provide the current format the variable has and the variable name.

You can get that information from Proc Contents or table properties.

 

The example values you show indicate that the variable must be character as none of the SAS supplied formats would treat both comma and period as the thousands separator your example implies. So do you want an actual numeric value or a character value without the comma and period?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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