Hello firends,
I wrote successfully a stored process that from the lasr table behind the report export a list in a csv file that is written on the server.
Now I want to download this file in a folder on my pc or get the possibility to download it from the browser...
I thougth to create in javascript a link to the path of the csv file, but the _webout process the path in the middle server...
How could I do this?
To get your CSV as a 'file download' (rather than displayed in the browser) you must firstly ensure you don't use the %stpbegin / end macros (as they will play with the output). You must also refrain from sending anything else to the _webout fileref.
You can now set the headers (so the browser knows the data received is a file download) and stream your CSV, as per the below. There is no way to set the save location using SAS, the end user has to do that themselves (eg by changing the default 'downloads' folder or manually choosing via the browser dialog).
data _null_;
rc=stpsrv_header('Content-type','text/plain');
rc=stpsrv_header('Content-disposition',"attachment; filename=YOURCSVNAME.csv");
run;
data _null_;
file _webout;
infile "/yourcsvlocation/your.csv";
input;
put _infile_;
run;
To get your CSV as a 'file download' (rather than displayed in the browser) you must firstly ensure you don't use the %stpbegin / end macros (as they will play with the output). You must also refrain from sending anything else to the _webout fileref.
You can now set the headers (so the browser knows the data received is a file download) and stream your CSV, as per the below. There is no way to set the save location using SAS, the end user has to do that themselves (eg by changing the default 'downloads' folder or manually choosing via the browser dialog).
data _null_;
rc=stpsrv_header('Content-type','text/plain');
rc=stpsrv_header('Content-disposition',"attachment; filename=YOURCSVNAME.csv");
run;
data _null_;
file _webout;
infile "/yourcsvlocation/your.csv";
input;
put _infile_;
run;
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.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.