The SAS Output Delivery System and reporting techniques

How to insert Excel formula in TITLE using ods tagsets.excelxp

Reply
Occasional Contributor
Posts: 9

How to insert Excel formula in TITLE using ods tagsets.excelxp

I am using ods tagsets.excelxp to create an Excel file and I am trying to place the Excel formula =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255) in TITLE. What the formula does is to return the name of the current sheet.

 

I know how to insert that formula in the table with PROC REPORT:

  define test / style(column)={tagattr='formula:MID(CELL("filename",RC[-1]),FIND("]",CELL("filename",RC[-1]))+1,255)'};

But I have no idea how to do that in TITLE. Anybody can help?

 

The desired output looks like this:

Capture.PNG

Super User
Posts: 17,907

Re: How to insert Excel formula in TITLE using ods tagsets.excelxp

Does it have to be the formula?

You must be hardcoding the sheet name somehow, could you use the same logic to move that variable into the TITLE statement?

 

One possibility is a single proc report that output to a single cell, so the text is inserted into a data set and then use proc report to transfer it to the cell.

Occasional Contributor
Posts: 9

Re: How to insert Excel formula in TITLE using ods tagsets.excelxp

I do not want to hard code the sheet name and I tried to use the same logic in title but I think the syntax is different and I don't know how to do it.

 

I thought about place it in a single cell but since it is a centered title you have to consider the width of the table and merge the cells which is too complicated.

Valued Guide
Posts: 505

Re: How to insert Excel formula in TITLE using ods tagsets.excelxp

If you are willing to use 'ods excel' this works. However you have to
open excel and hit 'F2<enter>' to execute the formula.


* this works;
%utlfkil(d:\xls\formulax.xlsx);  * delete;
ods excel file='d:\xls\formulax.xlsx';
ods excel options(sheet_name="class" sheet_interval="none");
proc report data=sashelp.class(keep=name age obs=5);
column ('=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)' name age);
run;quit;
ods excel close;

titlexls

Ask a Question
Discussion stats
  • 3 replies
  • 145 views
  • 0 likes
  • 3 in conversation