ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LisaSAS
Obsidian | Level 7

I have a query created where my output data table is showing 1089668.06 in the field - which is what I want.  However, when I do a PROC REPORT to Excel, the value changes to 1089668.1.  I'm not doing anything fancy in my PROC REPORT, mainly just want it to go to multiple excel sheets within one workbook.  A portion of my code is below..

ods _all_ close;

ods listing close;

ods tagsets.ExcelXP path = 'network path'

file = 'FileName.xls' style=MINIMAL;

ods tagsets.ExcelXP

options(sheet_name='WorksheetName'

frozen_headers="yes"

absolute_column_width='8.75, 6.25, 10.57, 7.43, 15, 8.14, 30.86, 10.57'

autofit_height='yes');

PROC REPORT DATA=WORK.TblFinal (WHERE = (where clause))

STYLE(REPORT) = [BACKGROUND=WHITE FOREGROUND=BLACK]

STYLE(COLUMN) = [BACKGROUND=WHITE FOREGROUND=BLACK FONT_SIZE=2]

STYLE(HEADER) = [BACKGROUND=WHITE FOREGROUND=BLUE BOLD FONT_SIZE=2];

COLUMNS SKU Channel ShipToCountry Territory ForeignSalesValue Units Description RetailerCode

;

DEFINE SKU / 'SKU' DISPLAY ;

DEFINE Channel / 'Channel' DISPLAY;

DEFINE ShipToCountry / 'Ship To Country' DISPLAY;

DEFINE Territory / 'Territory' DISPLAY;

DEFINE ForeignSalesValue / 'Foreign Sales Value' DISPLAY;

/*style={tagattr='format:#,###,##0.00'} previously I had this, so I took it out, but it did not seem to matter*/

DEFINE Units / 'Units' DISPLAY style={tagattr='format:#,##0'};

DEFINE Description / 'Descrption' DISPLAY;

DEFINE RetailerCode / 'Retailer Code' DISPLAY;

;RUN;quit;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  I am not sure how you say that TAGATTR does not make a difference. Perhaps you need to work with Tech Support. If you run the attached code, you should see that the SAS format is used in the ODS HTML output, but that in the ExcelXP output, only when you use TAGATTR do you have control over the number of decimal places. Here's an example of the output produced by the simplified version of your program listed below.

cynthia

 

Shows that TAGATTR is needed:

undefined

 

SAS code:

ods _all_ close;

 

ods html file='c:\temp\test_decimal.html';

 

ods tagsets.ExcelXP path = 'c:\temp'

file = 'test_decimal.xml' style=MINIMAL;

  

options(sheet_name='test_decimal');

PROC REPORT DATA=sashelp.class nowd

STYLE(REPORT) = [BACKGROUND=WHITE FOREGROUND=BLACK]

STYLE(COLUMN) = [BACKGROUND=WHITE FOREGROUND=BLACK FONT_SIZE=2]

STYLE(HEADER) = [BACKGROUND=WHITE FOREGROUND=BLUE BOLD FONT_SIZE=2];

COLUMNS name age sex height weight;

 

define name / order;

define age / f=z6.2 'age with z6.2 SAS format';

DEFINE height / 'height with tagattr' DISPLAY f=6.2

                style={tagattr='format:##0.00'} ;

DEFINE weight / 'weight without tagattr' DISPLAY f=6.2;

RUN;

ods _all_ close;

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  I am not sure how you say that TAGATTR does not make a difference. Perhaps you need to work with Tech Support. If you run the attached code, you should see that the SAS format is used in the ODS HTML output, but that in the ExcelXP output, only when you use TAGATTR do you have control over the number of decimal places. Here's an example of the output produced by the simplified version of your program listed below.

cynthia

 

Shows that TAGATTR is needed:

undefined

 

SAS code:

ods _all_ close;

 

ods html file='c:\temp\test_decimal.html';

 

ods tagsets.ExcelXP path = 'c:\temp'

file = 'test_decimal.xml' style=MINIMAL;

  

options(sheet_name='test_decimal');

PROC REPORT DATA=sashelp.class nowd

STYLE(REPORT) = [BACKGROUND=WHITE FOREGROUND=BLACK]

STYLE(COLUMN) = [BACKGROUND=WHITE FOREGROUND=BLACK FONT_SIZE=2]

STYLE(HEADER) = [BACKGROUND=WHITE FOREGROUND=BLUE BOLD FONT_SIZE=2];

COLUMNS name age sex height weight;

 

define name / order;

define age / f=z6.2 'age with z6.2 SAS format';

DEFINE height / 'height with tagattr' DISPLAY f=6.2

                style={tagattr='format:##0.00'} ;

DEFINE weight / 'weight without tagattr' DISPLAY f=6.2;

RUN;

ods _all_ close;

LisaSAS
Obsidian | Level 7

Cynthia,

Thank you for your quick response.  When I stated the TAGATTR did not make a difference, based on how I was using it, it was not.  However, once I looked at your code, I realized I did not have the f=10.2 along with it, which was needed.

 

Here's what I had, which did not work

DEFINE ForeignSalesValue / 'Foreign Sales Value' DISPLAY

style={tagattr='format:#,##0.00'};

 

Here's what I changed it to, which did work!

DEFINE ForeignSalesValue / 'Foreign Sales Value' DISPLAY f=10.2 style={tagattr='format:##0.00'};

 

Again, thank you!

...I've been trying to find exactly what the f= is, would you have anything to point me in the right direction?

Cynthia_sas
SAS Super FREQ
Hi:
F= is an abbreviation for FORMAT=. So if you know what a SAS format is from taking Programming 1, then you can refresh your info about formats in the Programming 1 class. Or look at the DEFINE statement documentation for how F=/FORMAT= is used.

Or, look in the documentation for the section on FORMATS used in SAS.

cynthia

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4356 views
  • 0 likes
  • 2 in conversation