1
votes

I have a dataset which has many variables all with numerical values wil decimals.

A
12.456756
134.677546
1.44563
86.56674998675

I want only two decimals in the variable I used format but it is only for display.

data want;
set have;
format A best5.2;
run;

But when I copy the dataset to another library or Oracle it shows the whole decimal values., how can I cut the value only to two decimal places?

2

2 Answers

3
votes

Use the ROUND() function.

data have ;
  input A;
cards;
12.456756
134.677546
1.44563
86.56674998675
;

data want ;
   set have ;
   b = round(a,0.01);
   put @5 a @20 b ;
run;

12.456756      12.46
134.677546     134.68
1.44563        1.45
86.566749987   86.57
0
votes

One easy workaround would be to convert the formated numeric value to a character value. When importing this in another database, the character value is not related to any formates, but only a string. You will have to convert it back to numeric then, but at least the other database does not need to know something about the SAS-Formates:

data want;
set have (rename=A=Atemp);
A= put(Atemp,best5.2);
drop Atemp;
run;