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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.