- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data ex;
a=23.964 ;
run;
create new variable and should be in numeric format only
how to directly we can divide the number number with one decimal
ex: 23.9
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just use a numeric format with one decimal, e. g.
format a 8.1;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@thanikondharish wrote:
Sorry I need exact number If I use your format it is showing 23
Bullshit. See @PGStats post (variable c).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Kurt_Bremser I believe applying format 8.1 would actually cause a to show up as 24.0 (not 23.9, as in @PGStats's example c), since rounding is also applied. But it would definitely have a digit after the decimal point, like you indicated.
data ex; a=23.964 ; format a 8.1; run; proc print; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@thanikondharish wrote:
Sorry I need exact number If I use your format it is showing 23
On top of what was already said, this (rounding up) is mathematically correct behavior for values where the first "discarded" digit is 5 or greater, and should usually be applied.
"Exact number" is of course a very funny term when you are actively reducing precision in the first place. By applying a format with a limited number of digits, you have already thrown the concept of "exact" over board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
b = floor (a*10)/10;
if the object is to always round down to multiples of 0.1
otherwise you may need to provide more rules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data ex;
a = 23.964 ;
b = round(a, 0.1);
c = int(a*10)/10;
format b c 8.1;
run;
proc print; run;
Obs. a b c 1 23.964 24.0 23.9
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just remember that by converting to 23.9 using the above methods (except formatting), this number cannot be represented exactly in binary, and so that may cause issues.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc format ;
picture fmt
low-high='0009.9';
run;
data ex;
a = 23.964 ;
format a fmt.;
run;
proc print;run;