BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mnithinshetty
Obsidian | Level 7

Hi,

I am displaying descriptive statistics in a table output in RTF format.

I would like to remove trailing zeros after decimal point in character data field without disturbing any leading and trailing spaces.

if I remove spaces it will disturb my decimal alignment in table display output.

 

For example.

Original  Expected result
60.0000 60
45.500 45.5
100 100
33.30 33.3
25.010 25.01
43.001010 43.00101

 

Kindly Suggest a solution for this issue.

Please do let me know if you need more detail.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
input have $char40.;
if findc(have,'.') then want=prxchange('s/\.\s*$//',1,prxchange('s/0+\s*$//',1,have));
else want=have;
cards;
 60.0000	
 45.500
100	
 33.30	
 25.010
 43.001010
;

View solution in original post

2 REPLIES 2
Ksharp
Super User
data have;
input have $char40.;
if findc(have,'.') then want=prxchange('s/\.\s*$//',1,prxchange('s/0+\s*$//',1,have));
else want=have;
cards;
 60.0000	
 45.500
100	
 33.30	
 25.010
 43.001010
;
mnithinshetty
Obsidian | Level 7

Thank you for the solution.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 693 views
  • 1 like
  • 2 in conversation