BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NathanOch
Obsidian | Level 7

Is there a way to use prompt values from the stored process in the sheet name of your ODS Tagsets.excelxp output?

 

Thanks,

Nate

1 ACCEPTED SOLUTION

Accepted Solutions
NathanOch
Obsidian | Level 7

Turns out if you put the ODS Tagsets statement AFTER the %stpbegin statement and exclude the BODY statement you can successfully use SHEET_NAME.

View solution in original post

6 REPLIES 6
Timmy2383
Lapis Lazuli | Level 10
Sure. Just create a text box prompt or something then include SHEET_NAME="&SHEET" in the ODS TAGSETS.EXCELXP options (assuming you name your prompt SHEET) .

You might also need SHEET_INTERVAL="none", but can't remember off the top of my head.
NathanOch
Obsidian | Level 7

That's what I thought, but it seems my BODY statement overrides the SHEET_NAME statement and without the BODY statement nothing is generated.

Timmy2383
Lapis Lazuli | Level 10
Can you provide the code?
NathanOch
Obsidian | Level 7

Here is my output statement:

 

*ProcessBody;

%global _odsest _odsstyle _odsstylesheet;

%let _odsest=html;

*%let _odsstyle=analysis;

%let _odsstylesheet=;

data _null_;

/* Set HTTP headers */

rc = stpsrv_header('Content-type','application/vnd.ms-excel');

 

/* Prompt to SAVE or OPEN the attachment file named test.xls using Excel */

rc = stpsrv_header('Content-disposition','attachment; filename=Open_Inventory_List.xls');

/* OR */

/* Open results directly to Excel (browser-dependent) */

/* rc = stpsrv_header('Content-disposition',"inline"); */

 

run;

ODS LISTING CLOSE;

*%let _ODSSTYLE=analysis;

ODS TAGSETS.ExcelXP options(sheet_name="&new_Client-&new_Sub_Client" sheet_interval="none" embedded_titles='yes') BODY="Open_Inventory_List" /*style=analysis*/;

%stpbegin;

 

 

...my proc print statement...

 

%stpend;

Vince_SAS
Rhodochrosite | Level 12

Try this simplified code:

 

*ProcessBody;

 

%let RV=%sysfunc(appsrv_header(Content-type,application/vnd.ms-excel));
%let RV=%sysfunc(appsrv_header(Content-disposition,attachment; filename="Open_Inventory_List.xml"));

 

ods _all_ close;

 

ods tagsets.ExcelXP file=_webout style=analysis;

 

ods tagsets.ExcelXP options(sheet_name="&NEW_CLIENT-&NEW_SUB_CLIENT"
                            sheet_interval='none'
                            embedded_titles='yes');

 

* Your proc print statement here;

 

ods tagsets.ExcelXP close;

 

Adapted from page 18 of this paper:
http://support.sas.com/resources/papers/proceedings15/SAS1700-2015.pdf

 

Vince DelGobbo
SAS R&D

NathanOch
Obsidian | Level 7

Turns out if you put the ODS Tagsets statement AFTER the %stpbegin statement and exclude the BODY statement you can successfully use SHEET_NAME.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1307 views
  • 1 like
  • 3 in conversation