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.
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
;
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
;
Thank you for the solution.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.