SAS Office Analytics, SAS Add-In for Microsoft Office, and other integrations

BEST-format, with comma as decimal point

Reply
N/A
Posts: 0

BEST-format, with comma as decimal point

Hi

I use commas as standard decimal point. It's important when you work with export to excel (swedish version) from WRS. I want to use a format like Best-format, where I exchange dot with comma. I could use the NUMX-format, but then I'll get decimals even for the integer (which stands for 90 % of the values). I want to suppress the decimals when it is a integer, just like the best-format. How do I solve that, without creating a char?

Code:
data test;
x = 4.5;
y = 4.5;
z = 4.5;
output;
x = 4;
y = 4;
z = 4;
output;
format x best. y numx. z numx6.1;
run;
proc print;run;

Result:
x y z Expected
4.5 5 4,5 4,5
4 4 4,0 4 Message was edited by: RoseBowl
SAS Super FREQ
Posts: 8,820

Re: BEST-format, with comma as decimal point

Hi:
You have to compare apples to apples. NUMX format is closer to the w.d format -- NOT the BEST. format. It says in the doc (about NUMX) that:
The NUMXw.d format is similar to the w.d format except that NUMXw.d writes numeric values with a comma in place of the decimal point.


and then, if you look at the doc for the w.d format:
The w.d format rounds to the nearest number that fits in the output field. ... If d is 0 or you omit d, w.d writes the value without a decimal point.


It seems to me that everything is working as designed. So this modification of your program:
[pre]
data test;
x = 4.5;
xx = 4.5;
y = 4.5;
z = 4.5;
output;

x = 4;
xx = 4;
y = 4;
z = 4;
output;

format x best. xx 6. y numx. z numx6.1;
label x = 'x*best.'
xx = 'xx*w.d without d'
y = 'y*numx.'
z = 'z*numx6.1';
run;

proc print data=test split='*';
run;

[/pre]
produces this output...where you can see that numx without a 'd' is working the same way that the w.d works without a 'd' .
[pre]
x xx y z
Obs best. w.d without d numx. numx6.1

1 4.5 5 5 4,5
2 4 4 4 4,0

[/pre]

Since you said that you were exporting from WRS, your best bet for help might be to contact Tech Support. I can't think of a solution using SAS-supplied formats. It seems that what you'd like to have is a BESTX format, but since we don't have that, you may have to find some other workarounds.

cynthia
N/A
Posts: 0

Re: BEST-format, with comma as decimal point

Thanks, I guess ;-)

You're right, I need a BESTX format. I'll try to find a workaround instead.

/Thomas
(alias RoseBowl)
Ask a Question
Discussion stats
  • 2 replies
  • 1067 views
  • 0 likes
  • 2 in conversation