BookmarkSubscribeRSS Feed
jins
Fluorite | Level 6
HI,
If I run the code below, why is there _webout.html and _webout.xls links. I just want the ok.xlsx
file to download. Is there a way to do it?

* Create the Excel XML output and associate with the job;
filename xmlfile filesrvc parenturi="&SYS_JES_JOB_URI"
name='_webout.xls'
contenttype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
contentdisp="attachment; filename=ok.xlsx";

ods excel file=xmlfile options(sheet_name="chk" frozen_headers='1');

proc print data=sashelp.class noobs;
title 'test3 ods excel mimetype=application/vnd.ms-excel';
run;
ods _all_ close;
9 REPLIES 9
AllanBowe
Barite | Level 11

There is an excel download option in Data Controller for SAS - here is the SAS code behind the download service:  https://code.datacontroller.io/getrawdata_8sas.html

 

It uses this macro directly: https://core.sasjs.io/mp__streamfile_8sas.html

Here's an extract:

    filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
      contenttype='application/vnd.ms-excel'
      contentdisp="attachment; filename=&outname";

This works fine for DC customers.  How exactly are you "running" the code?  Are you deploying it as a Job and opening the URL using the JES Web App with the appropriate _PROGRAM parameter?

Or calling via the JES REST APIs?

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
jins
Fluorite | Level 6

deploying as a job and opening the URL using the JES Web App. What should be the _PROGRAM parameter in this case? It was a bit confusing in SAS docs...

AllanBowe
Barite | Level 11

The `_program=/should/be/the/path/to/your/job/in/sas/drive` WITHOUT a .sas extension

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
jins
Fluorite | Level 6

The parameter _output_type =none seems to suppress the creation of those links. Do you concur on this?

jins
Fluorite | Level 6

HI Allan,

 

I migrated the stored process from 9.4 to Viya 3.5. I've the options of either creating html, xlsx and pdf as a drop down. Unable to figure out as to how to set the options for the automatic download for each of the reports based on selection. If I select _output_type='none' then I get the following error:

ERROR: No logical assign for filename _WEBOUT.  

 if I set _output_type='ods_html5' or html, then I get the links of _webout.html and _webout.xls instead of automatic download for the selected report type. Any thoughts on this?

AllanBowe
Barite | Level 11

Hi jins - am happy to try and help but it may be easier to do this through a screen share.  Feel free to book a convenient slot with me using this link:  https://4gl.uk/book

 

We can then report back with the solution should we find one.

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
jins
Fluorite | Level 6

HI Allan,

I can set that up later with an example but had a question if the following can be streamed if i am using tagset.tableeditor? (i've set _output_type as none in parameter)

%if &outputtp=HTML %then %do;
* Create the Excel XML output and associate with the job;
filename htmlfile filesrvc parenturi="&SYS_JES_JOB_URI"
name='_webout.json'
contenttype='text/html'
contentdisp="attachment; filename=ok.html";

*ods html file=htmlfile;
ods tagsets.tableeditor file='htmlfile'
style=styles.MyStyle
/*options(autofilter="YES"
autofilter_table="1"
autofilter_width="6em"
autofilter_endcol= "7"
frozen_headers="YES"
frozen_rowheaders="YES"
)*/ ;

proc print data=sashelp.class noobs;
title 'Test ODS HTML';
run;
ods tagsets.tableeditor close;
ods listing;
%end;   

 

AllanBowe
Barite | Level 11

You can stream ANYTHING you like!  Generally I'd look to create the file, then just stream it as it is, rather than using ODS but it should still work.

I had a realisation about this - are you creating the Jobs manually (not using SASjs)?

If so, have you set the option to remove the automatic JES macros?  `_addjesbeginendmacros=false`

 

These work similarly to the `stpbegin` and `stpend` macros in SAS EBI, and can affect the usability of the _webout destination.

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
jins
Fluorite | Level 6
 

HI,

 

Say I created this file test.html in a location as follows....

ods tagsets.Tableeditor file='/xxxx/xxx/xx/test.html'

 

How do I call this created file (test.html) to download using the filename filesrvc statements?

 

Thanks for your patience!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 9 replies
  • 1851 views
  • 1 like
  • 2 in conversation