ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
mj007
Calcite | Level 5

I am trying to use ods excel to output a sas data set to excel while at the same time adding a computed column as an excel formula.  The data set exports to excel just fine but the computed column just has periods (.) as values....no formula.  I have tried absolutely everything and nothing seems to work...as if SAS is completely ignoring the tagattr altogether.  I am well aware I could just do this calculation in SAS then export the resolved value, this is just an example that I am playing with to eventually scale up to a larger program that must export excel formulas to excel and not be calculated by SAS.

 

 

ods excel file="C:\temp.xlsx";
data _null_; set sashelp.class end=done; if _n_ = 1 then do; declare odsout t(); t.table_start(); t.row_start(); t.format_cell(data: 'Name'); t.format_cell(data: 'Height (ins)'); t.format_cell(data: 'Weight (lbs)'); t.format_cell(data: 'derived'); t.row_end(); end; t.row_start(); t.format_cell(data: name); t.format_cell(data: height); t.format_cell(data: weight); t.format_cell(data: .,style_attr: 'tagattr="formula:RC[-1]-RC[-2]"'); t.row_end(); if done then t.table_end(); run; ods excel close;

 

9 REPLIES 9
data_null__
Jade | Level 19

I copied your program and ran it and it looks to be working correctly to me.  

 

Capture.PNG

Reeza
Super User

What version of SAS are you using?

 

Make sure the formula option is on, explicitly?

mj007
Calcite | Level 5

using SAS9.4M4.

 

I get no warnings or errors in the SAS log

Cynthia_sas
SAS Super FREQ

Hi:

  When I run your code in 9.4 M6, this is what I get:

Cynthia_sas_0-1588796485531.png

It looks like the formula is being put into the cell. You might want to work with Tech Support on this question if this doesn't work for you in 9.4 M6.

 

Cynthia

ballardw
Super User

And works for Libre Office Calc.

 

Perhaps you can share the LOG you get when there are no results in the calculated column?

mj007
Calcite | Level 5
I am thinking this might be the issue...I am only on SAS 9.4M4.
ballardw
Super User

@mj007 wrote:
I am thinking this might be the issue...I am only on SAS 9.4M4.

That's the version I ran successfully.

mj007
Calcite | Level 5
It runs successfully on mine as well...however when you look at excel file there is no formula in the cells. Is this case with you?
Reeza
Super User
Cynthia's screen shot shows the formula in the formula bar.

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
  • 9 replies
  • 2087 views
  • 0 likes
  • 5 in conversation