Desktop productivity for business analysts and programmers

SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

Reply
Occasional Contributor
Posts: 17

SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

Hello All.

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.


%let _ODSDEST=TAGSETS.csvall;

%stpbegin;

ods tagsets.csvall options(sheet_name="Testing");

Proc Print data=work.testing;

run;

ods tagsets.csvall close;

%stpend;

In SAS 9.3 I have exported datasets to .txt files using the following code:

Data _null_;

       set work.testing;

       File "pathway\file.txt";

run;

Is there anyway in SAS EG 5.1 to export my dataset to my local hard drive and not automatically open it?


Thank you.



--Chris.

Super User
Posts: 11,105

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

Occasional Contributor
Posts: 17

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

Super User
Posts: 11,105

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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?

PROC Star
Posts: 1,143

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

Tom

Occasional Contributor
Posts: 17

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

Occasional Contributor
Posts: 17

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

Occasional Contributor
Posts: 17

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

SAS Super FREQ
Posts: 8,814

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

Hi:

  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.

cynthia

Occasional Contributor
Posts: 17

Re: SAS EG 5.1 Stored Process To Export/Download Dataset to .TXT Format

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.

Ask a Question
Discussion stats
  • 9 replies
  • 1049 views
  • 0 likes
  • 4 in conversation