The SAS Output Delivery System and reporting techniques

remove trailing zeros for all decimal numeric feilds

Reply
Regular Contributor
Posts: 174

remove trailing zeros for all decimal numeric feilds

I have a dataset that I want to remove the trailing zeros for all decimal numeric variables. Is there any easy way to do this? I used the best and it did not work.

Trusted Advisor
Posts: 1,848

Re: remove trailing zeros for all decimal numeric feilds

Addapt the format of the numeric variables to showm required decimal digits.

Super User
Posts: 6,903

Re: remove trailing zeros for all decimal numeric feilds

No, there's no easy way.  If you want to spend a lot of time for a limited result that approximates what you are asking for, here's a program you can fiddle with:

 

proc format;

value nozero 0=' 0' 1=' 1' 2=' 2' 3=' 3' 4=' 4' 5=' 5' 6=' 6' 7=' 7' 8=' 8' 9=' 9' 10='10' 11='11' other=[5.2];

run;

 

data test;

do j=1 to 11 by 0.01;

output;

end;

run;

 

proc print data=test;

format j nozero.;

run;

Super User
Posts: 13,889

Re: remove trailing zeros for all decimal numeric feilds


@Melk wrote:

I have a dataset that I want to remove the trailing zeros for all decimal numeric variables. Is there any easy way to do this? I used the best and it did not work.


Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

As it is we are having to guess what "did not work".

Regular Contributor
Posts: 174

Re: remove trailing zeros for all decimal numeric feilds

[ Edited ]

Horrible solution I came up with for this thread, but I just ended up fixing it in the excel format and re-imported..

Ask a Question
Discussion stats
  • 4 replies
  • 306 views
  • 0 likes
  • 4 in conversation