BookmarkSubscribeRSS Feed
deleted_user
Not applicable
When i am trying to use proc report to xls through ODS , one variable output format , should display ex: $1123.24, But its not displaying " $" in xls ouput , It displaying only 1123.24 , .

Please guide me to get the the result output.
Thanks in advance.
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi,
What you have discovered is that even though you have a SAS format for your variables, Excel does not always honor or use the SAS format. There is a way to pass a Microsoft format from SAS to EXCEL, however. The method that you use will vary, depending on whether you are using ODS HTML, ODS MSOFFICE2K or ODS TAGSETS.EXCELXP to create a file that Excel can open.

The following code shows you how to pass a Microsoft format to Excel for MSOFFICE2K and EXCELXP destinations. It doesn't matter whether you have a detail report or an ordered report or a grouped report. ODS just sends the MS format in a way that Excel can understand. Please note that HTML based destinations use the HTMLSTYLE attribute to pass the format, while XML based destinations use the TAGATTR attribute to pass the format. For example, here's the way that the HTML TD tag is written in the output file when you use the MSOFFICE2K destination:
[pre]
<td class="Data" style=" text-align: right; mso-number-format:$#,###,###.##;"> $801</td>
[/pre]

and, here's the Spreadsheet Markup Language XML that is written in the output file when you use the EXCELXP destination:
[pre]
<Style ss:ID="data__r1" ss:Parent="data__r">
<Protection ss:Protected="1" />
<NumberFormat ss:Format="$#,###,###.##" />
</Style>

<Cell ss:StyleID="data__r1" ss:Index="3"><Data ss:Type="Number">801</Data></Cell>
[/pre]

For more information about Microsoft formats and how to specify them, consult this paper by Chevell Parker, which has some common MS format examples http://support.sas.com/rnd/base/ods/templateFAQ/Excel1.pdf
or consult the Microsoft documentation.

cynthia
[pre]
ods msoffice2k file='c:\temp\curr_mso.xls' style=sasweb;
proc report data=sashelp.shoes(obs=5) nowd;
column region product sales ;
define region / display;
define product / display;
define sales / sum
style={htmlstyle="mso-number-format:$#,###,###.##"};
run;
ods msoffice2k close;

ods tagsets.excelxp file='c:\temp\curr_xp.xls' style=sasweb;
proc report data=sashelp.shoes(obs=5) nowd;
column region product sales ;
define region / order;
define product / order;
define sales / sum
style={tagattr="$#,###,###.##"};
run;
ods tagsets.excelxp close;
[/pre]
deleted_user
Not applicable
Hi,
You can use
ods html ...............;
proc report data=test;
columns....
define amount format=dollar8.2;
;;;
;;;;
run;
ods html close;
Hope this helps...
Let me know if you have nay issues
Sireesha

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 617 views
  • 0 likes
  • 2 in conversation