BookmarkSubscribeRSS Feed
jaemin
Calcite | Level 5

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

3 REPLIES 3
Reeza
Super User

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.

jaemin
Calcite | Level 5

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.

rogerjdeangelis
Barite | Level 11
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 855 views
  • 0 likes
  • 3 in conversation