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.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
  • 6 replies
  • 1457 views
  • 1 like
  • 3 in conversation