BookmarkSubscribeRSS Feed
zdassu
Quartz | Level 8

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

6 REPLIES 6
SuryaKiran
Meteorite | Level 14

Did you try changing the format? What format does it have?

Provide some sample data you have and your required result.

Thanks,
Suryakiran
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

zdassu
Quartz | Level 8

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

singhsahab
Lapis Lazuli | Level 10

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;

zdassu
Quartz | Level 8

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

SuryaKiran
Meteorite | Level 14

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;
Thanks,
Suryakiran

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 2725 views
  • 0 likes
  • 4 in conversation