BookmarkSubscribeRSS Feed
danilodelve
Calcite | Level 5

Hi everyone,

 

I would like to write a SAS code (to insert in a Stored Process) that, in the same time, downloads a zip file from a server and opens in my browser a new tab printing some messages. So far, I coded this program:

 

Data _null_;
	file _webout recfm=s;
	infile "&filepath./&filename." recfm=n;
	if _n_ = 1 then do;
		rc = stpsrv_header('Content-type','application/zip');
		rc = stpsrv_header("Content-disposition","attachment; filename=&filename.");
		put "<label><center><b>My message to print in a new web page</b></center></label>";
	end;
	input c $char1.;
	put c $char. @@;
run; 

The macro variables &filepath and &filename contain, respectevely, the path and the name of the zip file that I want to download. The download ends successfully, but I cannot get my new web page with the message. If I run the put statement with the message alone in a data step, it works. On the contrary, if I try to run the put task and the download task in either the same data step (as in the previous code), or in two different data steps, only the download ends successfully. 

 

Can you help me?

 

Thanks 

1 REPLY 1
AllanBowe
Barite | Level 11

You could try playing with the headers to do a 302 redirect but I'm not sure if it will work

 

The "proper" way of handling this would be to have a frontend that:

1.  requests the zip download
2.  redirects to the desired page

 

This is how we manage it using Data Controller for SAS.

 

 

/Allan
MacroCore library for app developers
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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 761 views
  • 0 likes
  • 2 in conversation