Uploading a file (via the web) into SAS

12

I must recommend that you check out this example from pg 70 of the SAS Stored Process Developers Guide. http://support.sas.com/documentation/cdl/en/stpug/61271/PDF/default/stpug.pdf

This is a pretty sweet example of how to upload a file from your machine (via Internet Explorer) into the SAS System.

A custom form can be created in html - or within data _null_ steps within a Stored Process. Modify the highlighted value= to the path of the subsequent stored process that you will run.

<form action="StoredProcessWebApplicationURL" enctype="multipart/form-data" method="post">
</form>
<input type="hidden" name="_program" value="/Path/StoredProcessName">
<table border="0" cellpadding="5">
<tbody>
<tr>
<th>Choose a file to upload:</th>
<td><input name="myfile" type="file" /></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" /></td>
</tr>
</tbody></table>

Then the stored process (the value that correspond to the path highlighted above "/Path/StoredProcessName") that runs when the user selects the "submit" button will need to use the hidden parameters available when using the 'file' input type. Table 5.5 in the document lists these values, and the example at the bottom of page 71 shows how to simply use a data null infile process to grab the contents of the uploaded file in SAS.

Share

About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

12 Comments

  1. Angela

    I re-wrote the html and got this working. Thanks for your help and speedy reply. Very much appreciated.

    Thanks again,

    Nigel

      • Angela Hall

        Hi Nigel! Congratulations on the upgrade & continued use of this trick :)
        According to mozilla.org "The HTTP 415 Unsupported Media Type client error response code indicates that the server refuses to accept the request because the payload format is in an unsupported format.
        The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly."

        Are you still using the html form with encoding as: enctype="multipart/form-data"?

  2. Nigel Crask on

    I have tried to use this method to upload a file but I get the followng error from my stored procedure:

    WARNING: Apparent symbolic reference _WEBIN_FILEREF not resolved.

    It's as if the SAS Macro variables are not getting passed into the stored proc. Any help/advice would be appreciated.

    • Angela Hall
      Angela Hall on

      Nigel,
      I have had a similar situation & the problem was that my web form html has a typo. These automatic variables are only created when the web form has an type="file" input line.
      Such as:
      <td><input name="myfile" type="file" /></td>

      If this isn't the scenario for you, I would suggest creating a SAS Technical Support ticket or adding a comment on the Support Community for Stored Processes with some of your code.

      Angela

  3. Pingback: Troubleshooting a web file upload - Real BI for Real Users

  4. As Sonny stated above - this is only recently available in 9.2.Workarounds in 9.1.3 would involve technology outside of SAS (such as JS/Java/etc) that I'm not as familiar with.

Back to Top