03-16-2015 01:39 PM
I am currently working SAS Enterprise Guide 5.1 and I am trying to have my stored process automatically download a dataset to my local hard drive (just trying to set the pathway to my desktop to see if it will work). I have been trying all formats (.xls, .rtf, .pdf) and haven't been able to find a way to get it to work. I have been able to use ODS TAGSETS to have my dataset export to Excel and open up in Excel. However, I would ideally like it if the file would be exported to my computer and then I could open it whenever I chose to.
ods tagsets.csvall options(sheet_name="Testing");
Proc Print data=work.testing;
ods tagsets.csvall close;
In SAS 9.3 I have exported datasets to .txt files using the following code:
Is there anyway in SAS EG 5.1 to export my dataset to my local hard drive and not automatically open it?
03-16-2015 02:16 PM
The data step code works in a code node the same as always. The ODS destinations open by default unless you set the options not to open any results.
03-16-2015 03:33 PM
The problem that I have when using the data step method is that I get an error message that I can't access the output pathway. I was setting my pathway to "C:\users\username\desktop\testing.txt" and that is what seemed to trigger the error.
03-16-2015 03:58 PM
Without more details it is hard to diagnose but at a guess you're running with some flavor of SAS server and the path to the output needs to be something the server can see. Where is the output for the CSVALL going?
03-16-2015 04:02 PM
Since you're using a stored process, I believe that you're using a SAS server. A reference to a location on your "C:" drive probably wouldn't make any sense in the context of a server; you'd be trying to update the C: drive on the server (assuming it's even running Windows).
First, you need to find out from your SAS server administrator which directory on the server you should use for output data. Then the issue of writing the data to somewhere that you can see it from your PC comes up. Start with a discussion with your administrator; they may have guided people through this before.
03-16-2015 04:10 PM
I am running on a SAS server.
I was thinking that it had to be something that server could see. I was able to upload files to server from my desktop using a custom HTML form, so I have been trying to see if it is possible to export a file to my desktop.
When I'm using the CSVALL, the output is being opened in Excel automatically at the end of the stored process.
03-16-2015 04:42 PM
Would the logic of the export be in any way similar to that of the export wizard in enterprise guide? If I am connected to the SAS server and I export a dataset in my process flow, not within a stored process, I can easily export the file to my desktop.
03-16-2015 05:24 PM
The error message that I receive when I use my local machine pathway is:
ERROR: Insufficient authorization to access /sas/sas93/compute_config/Lev1/SASApp/C:\users\username\desktop\test.pdf.
I've come across some articles about some customs tasks that can be installed to export data to your local machine, but this stored process is going to eventually be used by many people and I do not want to have each user install the .dll files in order to run the custom task.
03-16-2015 06:15 PM
With the stored process and your error message, the fact that you get this /sas/sas93/compute_config/Lev1/SASApp/ (indicating a SASApp server) inserted in front of your C: drive location C:\users\username\desktop\test.pdf means that you CANNOT write to your local C: drive with the current syntax you have. You can work with your SAS Administrator to get a folder on the server where you have write access or a folder on a server that SAS can connect to (not your C: drive) so that you can write the file. Then, once the file is on the server, you can download it to your C: drive.
The thing I find confusing is that you said at the beginning that you wanted to send your stored process output to a .TXT file, but you show a .PDF file in the ERROR message. Partly, the stored process results that you can get depend on the client application that you are using to run the stored process. For example, PowerPoint, as a client application can only receive certain types of output and could not, for example, receive CSV or TXT output from a stored process. Similarly, Word, as a client application can only accept/receive RTF, HTML and SASReport XML from a stored process. So you did not say what client application you were using to run the stored process, which means there's not really a good answer to your question without that information.
But, if you are 1) using a web client, like the Stored Process Web App or 2) like the Information delivery portal, you CAN write a PDF file or a TXT file or a CSV file for that matter using _webout and the STPSRV_HEADER function to specify the content-type header that should be sent with the output. There are quite a few examples of this in the stored process forum (using _webout and STPSRV_HEADER).
Or, you could look in the documentation or on support.sas.com for examples, like this one 12994 - Creating a PDF, CSV or RTF file when running the SAS® Stored Process Server.
03-17-2015 07:51 AM
Thank you Cyntia. I will look into that documentation.
I am running the stored process using a web client (sorry for leaving that part out).
I will see if I can get in touch with the admin and see if its possible to give me a folder on the server and try that method to download the file.