- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to format these values with 3 decimal places but I keep getting the leading zeroes in front of the decimal place
I'm using the following code
format AVG 9.3;
format SLG 6.3;
format OBP 9.2;
format ISO 6.3;
format AVG 9.3;
format SLG 6.3;
format OBP 9.3;
format ISO 6.3;
format AVG 9.3;
format SLG 6.3;
format AVG 9.3;
format SLG 6.3;
format AVG 9.3;
format SLG 6.3;
format OBP 9.2
I have attached the Excel output from SAS, please take a look at the AVG, SLG, OBP and ISO columns O, P,Q and R on the attached spreadsheet and advise
- Tags:
- decimal
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@philjones820 wrote:I'm trying to format these values with 3 decimal places
OK
but I keep getting the leading zeroes in front of the decimal place
Why do you think the leading zero to the left of the decimal point has anything to do with the 3 decimal places to the right of the decimal point?
Can you be ***sure*** your data you want to display without a leading zero is < 1?
What would you expect/desire to display in the below example?
data test;
a=0.123456789;
b=a;
c=a;
output;
a=123.123456789;
b=a;
c=a;
output;
a=123456.123456789;
b=a;
c=a;
output;
format a best. b 9.3 c 4.3;
run;
Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The Excel is output is fine now
have a number 0.573 that I need to format with 3 decimal places in SAS and I though format 9.3 would do that, I don't know if it is supposed to give me 3 decimal places after the 0 like it is now or if I need to remove the 0?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000199377.htm
The 9.3 format will display the number right aligned in a 9 character width field with 3 decimal places to the right of the decimal point. It will display the integer portion to the left of the decimal point. If your data is < 1 there will be a zero for the integer portion.
IMO suppressing the leading zero in this scenario would be confusing. I've never had need to do so.
Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@philjones820 wrote:
The Excel is output is fine now
have a number 0.573 that I need to format with 3 decimal places in SAS and I though format 9.3 would do that, I don't know if it is supposed to give me 3 decimal places after the 0 like it is now or if I need to remove the 0?
It may help to show us what you expect the final result to actually look like. You will likely run into an EXCEL display issue. You need to create a custom display in Excel to no show the leading zero if you want to see .573 instead of 0.573.
Highlight the cell(s) in Excel, right click an select "Format Cells", go down and highlight the Custom entry. On the right where it says Type enter .000 and hit enter.
You don't mention or show how you are sending data to Excel from SAS. If using report procedure like Proc Print or Report you may be able to use the tagattr style option for the appropriate cell(s).
But if you do have values like 1223.456 that appear in the same column that is likely going to be a challenge to suppress the 0 for other cells in the column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sigh...I thought the Excel output was just a convenience to show the data. If he's trying to format the data *in* Excel then that's a whole different kettle of fish.
<frustration>
I sure wish folks would invest as much time in asking a question as they expect us in answering them.
</frustration>
Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content