Desktop productivity for business analysts and programmers

Uploading .XLSX File In Multiple Stored Processes

Reply
Occasional Contributor
Posts: 17

Uploading .XLSX File In Multiple Stored Processes

Good morning forum,

I am currently working on a set of chained stored processes (3 in total) in which the first stored process prompts the user to select a file that will be uploaded.  The stored process is using HTML forms to display the page and create the buttons and browser to select a file.  The form looks like this:

data form;
  format infile $char256.;
  input;
  infile=resolve(_infile_);
  cards;

<HTML>
<BODY bgcolor="#CAD6DA">
<FORM ACTION="&_URL" method="post" enctype="multipart/form-data">
<INPUT TYPE="HIDDEN" NAME="_program" VALUE="Path to Second Stored Process">
<INPUT TYPE="HIDDEN" NAME="submit" VALUE="submitted">
<table border="0" cellpadding="5">
<tr>
<td colspan="2">
<INPUT TYPE="file" NAME="Attach1" />
</td></tr>
<tr>
<td colspan="2">
<INPUT TYPE="submit" value="Upload">
</td></tr>
</table>
</FORM>
</BODY>
</HTML>
;
run;

data _null_;
  file _webout;
  set form;
  put infile;
run;

Once the 'Upload' button is selected, a second stored process is called and the selected file (a .xlsx file) is uploaded and proc sgplot is used to plot the data for visual representation of the uploaded file.

What I would like to happen is have 2 buttons on the second stored process.

  • One will be a 'Go Back' button if the data doesn't look right (maybe the wrong file was uploaded, format of file is incorrect, etc.) and allow the user to either fix the file or upload a different one.
  • The second button would be a 'Continue' button where a third stored process would be called.

The 'Go Back' button works fine to send the user back to the first stored process and allow for them to upload the file again.  The 'Continue' button, bringing the user to the third stored process is where my problem is.

In the third stored process, I would like the same uploaded file from the second stored process to be called and used in data steps.

Right now on the third stored process, I am having some difficulties

  1. If i try to upload the file again, I get the following error:
    ERROR: Unable to import, please specify a DATAFILE.
  2. If I don't try to upload the file and just call the data set, I get the following error:
    ERROR: WORK.XXXX.DATA does not exist.

The import code I am using is:

proc import out=excel
  file="%sysfunc(pathname(&_webin_fileref))"
  dbms=xlsx
  replace;
run;

Does anyone have any suggestions on how to either bring them dataset from the second stored process into the third, or be able to upload the file selected in the first stored process?

Thank you.

--Chris.

Regular Learner
Posts: 1

Re: Uploading .XLSX File In Multiple Stored Processes

Unless you establish a sessoion, data in the work library is deleted when chaining together different stored processes.

 

Try the technique described here and see if you are able to refernce WORK dataset after clicking continue.

 

http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/sessions.html

http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/sesssamp.html

Ask a Question
Discussion stats
  • 1 reply
  • 369 views
  • 0 likes
  • 2 in conversation