## Numeric format with decimal comma

Solved
Occasional Contributor
Posts: 8

# Numeric format with decimal comma

Hi,

is there any SAS numeric format, that would return these outputs from these inputs:
INPUT: 1 --- OUTPUT: 1
INPUT: 1.1 --- OUTPUT: 1,1
INPUT: 1.1235 --- OUTPUT: 1,1235

?

Basically: I need some format with decimal comma, but the only one I have found is NUMXw.d. However that gives 1,0000 out of 1. Which is what I dont want.

V.Herrmann

Accepted Solutions
Solution
‎02-22-2017 04:20 AM
PROC Star
Posts: 2,363

## Re: Numeric format with decimal comma

No format does this afaik. bestx shoud but doesn't.

If you really need a format, you can build it:

``````
proc fcmp outlib=WORK.FUNCTIONS.TEMP;
function bestxx (NUMBER) \$ ;
return (translate(cat(NUMBER),',','.'));
endsub;
run;

options cmplib= WORK.FUNCTIONS;
proc format;
value bestxx other=[bestxx()];
run;

data _null_;
A= 1      ;put A= @11 A= bestxx.;
A= 1.1    ;put A= @11 A= bestxx.;
A= 1.1235 ;put A= @11 A= bestxx.;
run;``````

A=1       A=1
A=1.1     A=1,1
A=1.1235  A=1,1235

All Replies
Contributor
Posts: 67

## Re: Numeric format with decimal comma

I think you want COMMAXw.d

Michelle
Solution
‎02-22-2017 04:20 AM
PROC Star
Posts: 2,363

## Re: Numeric format with decimal comma

No format does this afaik. bestx shoud but doesn't.

If you really need a format, you can build it:

``````
proc fcmp outlib=WORK.FUNCTIONS.TEMP;
function bestxx (NUMBER) \$ ;
return (translate(cat(NUMBER),',','.'));
endsub;
run;

options cmplib= WORK.FUNCTIONS;
proc format;
value bestxx other=[bestxx()];
run;

data _null_;
A= 1      ;put A= @11 A= bestxx.;
A= 1.1    ;put A= @11 A= bestxx.;
A= 1.1235 ;put A= @11 A= bestxx.;
run;``````

A=1       A=1
A=1.1     A=1,1
A=1.1235  A=1,1235

Occasional Contributor
Posts: 8