- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I think most of you aware of a format COMMAw.d which prints number, say, 123456789.12 as
123,456,789.12
I'm trying to find quite similiar format which will print the same number in a manner
123 456 789.12
or even
123 456 789,12
Since I haven't find built in one I tried to create picture by myself using proc format
proc format;
picture test low-high='00 000 000 000 000.00';
run;o
Okay, it seems to work for the number I chose, but what about 20 digit length numbers?
According to SAS Help, I can't use picture string with more than 16 digits.
What to do in this situation? (P.s. Comma. format works fine with up to 40 digits).
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For your second alternative, it could be accomplished using the nlnum. format, just be sure to have the appropriate locale set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For your second alternative, it could be accomplished using the nlnum. format, just be sure to have the appropriate locale set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Any hint about specific locale?
I have Russia_Russian, but it's still uses comma as a 3digit separator, and I need a blank space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sweden has blanks... (sv_SE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
I wonder why Russian has commas... It's a question for SAS support: it must be blanks for digit separating and a comma for decimal.
upd. I used NLNUM. instead of NLNUMI for my locale. And it worked.
LinusH, thanks anyway!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A couple of things to note
- Windows and Unix SAS (unless I blinked and missed the upgrade) use the IEEE system of representing floating point numbers in 8 bytes. This restricts the accuracy of representing any integer to just short of 16 digits. MS Excel has the same limitation - try entering a 16 digit number and it will truncate the last digit to zero. SAS is better behaved but anything after the first 15 digits in your format cannot be relied on.
- Picture formats with decimals do not round to nearest decimal. Instead they always round down. This can catch you out because what looks like 12345.6700 when you view your table using best12.4 may be a tiny amount short of that and picture would represent it as 12345.6699.
Oracle uses a 12 byte internal representation for numeric values so you commonly see 23 digits specified. I believe you can have extended precision in FORTRAN, if that helps.
Richard in Oz
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Richard, thanks!
I've totally forgot about the 8 byte limitation for floats... Despite of seeing this fact in every computer science course I've ever taken.
Actually, I don't really need such an accuracy, I just need the format that will be universal (like any internal format).
So I can use it with numbers of different power (assuming the power of a column is the same through the dataset).
I.e. when I'm using a picture for the format, the number of digit selectors must be 16, but the place of decimal separator "." is predefined.
And that's a problem, because for different powers of the number (that I want to print) I'll need to redefine the format in order to have 16 digits and a "." in appropriate place.
Example:
1234567890.123456 and 123456789012345.6
I can use CommaW.D to set the correct formatting (without using the redifinition of format).
I can't use any picture created by proc format, because in both numbers, independently of (w.d), some part will be truncated.