Hi I have a large dataset consisting of 100 million rows, the data set has about 10 columns and 1 of the datasets has a number with about 10 decimal places, I would like to remove the decimal places to about 5 or 6 with out rounding up the number. I also want to keep all the other columns
Your help would be much appreciated
Did you try changing the format? What format does it have?
Provide some sample data you have and your required result.
It will also round the number if you change format.
@zdassu, this topic has been covered quite a lot. See:
https://blogs.sas.com/content/sgf/2016/12/15/truncating-decimal-numbers-in-sas-without-rounding/
To see either a character or numeric version.
My Apologies for the late reply as I have been away for a few days. find sample data below, I would like to retain all fields
INV_NUMBER Year MONTH Ref RECON LDZ START_DATE END_DATE
1019894 2018 2 5477456 -40.749103617360840 SE 2017-07-01 2017-07-31
1019894 2018 2 5477456 -42.901859291503540 SE 2017-08-01 2017-08-31
1019894 2018 2 5606613 47.443779198665370 SE 2018-02-01 2018-02-03
You can use floor function like below . Below is the example to consider 4 decimal places.
data test;
input i;
cards;
1.234567
;
run;
data test1;
set test;
i=floor(i*10000)/10000;
run;
thanks for your reply, my apologies for late reply as I have been away, how would I use floor function and retain the other fields as well?
See sample data below
My Apologies for the late reply as I have been away for a few days. find sample data below, I would like to retain all fields
INV_NUMBER Year MONTH Ref RECON LDZ START_DATE END_DATE
1019894 2018 2 5477456 -40.749103617360840 SE 2017-07-01 2017-07-31
1019894 2018 2 5477456 -42.901859291503540 SE 2017-08-01 2017-08-31
1019894 2018 2 5606613 47.443779198665370 SE 2018-02-01 2018-02-03
Did you check the blog @RW9 mentioned.
Something like this would work for you if your variable is numeric.
data have;
set have(rename=(RECON=RECON_));
RECON=INT(RECON_*100000)/100000;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.