<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export excel using stored process in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301011#M5119</link>
    <description>&lt;P&gt;Without having more details, my guess is that you are getting a message like this when you try to open the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;The file that you are trying to open, 'GL_Claims.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try changing the extension in your STPSRV_HEADER call to &lt;FONT face="courier new,courier"&gt;.xml&lt;/FONT&gt; to match the content of the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;rc = stpsrv_header('Content-disposition','attachment; filename=GL_Claims.&lt;STRONG&gt;xml&lt;/STRONG&gt;');&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Vince DelGobbo&lt;/P&gt;
&lt;P&gt;SAS R&amp;amp;D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2016 12:27:16 GMT</pubDate>
    <dc:creator>Vince_SAS</dc:creator>
    <dc:date>2016-09-27T12:27:16Z</dc:date>
    <item>
      <title>Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300939#M5114</link>
      <description>&lt;P&gt;Good morning everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My company is using SAS version&amp;nbsp;9.2 (TS2M3).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data table which I want to make available to users through browser. The thought is to create a stored process which will create a prompt to users to download an Excel file of the data table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried other solutions like PROC EXPORT but it is not working. The client sees an empty browser page when he chooses the stored process on the SAS portal.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was the most recent code which I used but with no results.&lt;/P&gt;&lt;P&gt;PROC EXPORT&lt;BR /&gt;DATA=VA_WORK.WRK_TEST_GL_CLAIMS&lt;BR /&gt;DBMS=CSV&lt;BR /&gt;OUTFILE="c:\gl_claims.csv"&lt;BR /&gt;REPLACE;&lt;BR /&gt;PUTNAMES=NO;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is how to create a stored process, where users will be able to download a dataset into an excel file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 07:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300939#M5114</guid>
      <dc:creator>GeorgeGiannako</dc:creator>
      <dc:date>2016-09-27T07:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300948#M5115</link>
      <description>&lt;P&gt;Well, I don't use Stored Processes so can't help there, however I will say that CSV != Excel. &amp;nbsp;CSV stands for Comma Separated Variable file, and is a text based delimited file format. &amp;nbsp;Excel doeshave some inbuilt functionality to process this data if the file extension is associated with Excel, however that isn't default behaviour. &amp;nbsp;Browsers don't have this functionality, so it should just show up as plain text in the browser. &amp;nbsp;As to why its not showing up, well a guess would be you are exporting the data to a file on your local machine - the C: drive - how will the web page know where this file is? &amp;nbsp;The web page would need a url to the file.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 08:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300948#M5115</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-27T08:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300950#M5116</link>
      <description>&lt;P&gt;I see. However, changing the csv to xls or xlsx does not work either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used some other piece of code i found in the community but it does not work either BUT it downloads a corrupted excel file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*ProcessBody;
data _null_;

rc = stpsrv_header('Content-type','application/vnd.ms-excel');
  
rc = stpsrv_header('Content-disposition','attachment; filename=GL_Claims.xls');

run;

/*ods tagsets.excelxp file= "c:\report.xml";
Proc tabulate data=GL_Claims.xml;
run;
ods tagsets.excelxp close;*/

%let _ODSDEST=TAGSETS.EXCELXP;

/* Create output */
%stpbegin;

  proc print data=VA_WORK.WRK_TEST_GL_CLAIMS;
  run;

%stpend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2016 08:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300950#M5116</guid>
      <dc:creator>GeorgeGiannako</dc:creator>
      <dc:date>2016-09-27T08:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300952#M5117</link>
      <description>&lt;P&gt;Create the stored process without using the stored process macros, as those occupy the _webout destination.&lt;/P&gt;
&lt;P&gt;Configure your STP as stream output.&lt;/P&gt;
&lt;P&gt;Use _webout as file reference for your CSV output file.&lt;/P&gt;
&lt;P&gt;To make it easier for the browser to handle the content, you can add (data _null_ step with file _webout;) the necessary HTML code that identifies the content type. HTML knowledge needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively:&lt;/P&gt;
&lt;P&gt;If you have a webserver running where SAS resides, you can store the CSV in a location that is within the DocumentRoot of the webserver; the STP should then create a simple webpage containing the URL of the file. That way, the webserver will automatically flag the content type.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 08:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300952#M5117</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-27T08:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300954#M5118</link>
      <description>&lt;P&gt;I would sort out the base code first then before worrying about the download. &amp;nbsp;Why does the file say corrupt? &amp;nbsp;Run that part on your local machine, make sure to apply a style and correct output. &amp;nbsp;I have got that sometimes where my proc report doesn't have a columns statement (although that might just be my setup). &amp;nbsp;Not sure what bit in that code is what your talking about, the commented out section:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token comment"&gt;/*ods tagsets.excelxp file= "c:\report.xml";
Proc tabulate data=GL_Claims.xml;
run;
ods tagsets.excelxp close;*/&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Doesn't seem right (unless you have a dataset called XML). &amp;nbsp;And the other, the proc print doesn't seem to have any ods statements associated with it - this may just be that system I do not know. &amp;nbsp;Normally to produce a file I would see:&lt;/P&gt;
&lt;PRE&gt;ods tagsets.excelxp file="...\file.xml" style=statistical options(sheet_name="Sheet");
proc report data=your_data nowd split="*";  
  columns _all_;
  define col1 / "Hello";
  define col2 / "World";
run;
ods tagsets.excelxp close;&lt;/PRE&gt;
&lt;P&gt;Note that Excel does qeustion the opening of some filetypes, but that doesn't mean the file is corrupted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 08:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/300954#M5118</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-27T08:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301011#M5119</link>
      <description>&lt;P&gt;Without having more details, my guess is that you are getting a message like this when you try to open the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;The file that you are trying to open, 'GL_Claims.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try changing the extension in your STPSRV_HEADER call to &lt;FONT face="courier new,courier"&gt;.xml&lt;/FONT&gt; to match the content of the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;rc = stpsrv_header('Content-disposition','attachment; filename=GL_Claims.&lt;STRONG&gt;xml&lt;/STRONG&gt;');&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Vince DelGobbo&lt;/P&gt;
&lt;P&gt;SAS R&amp;amp;D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 12:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301011#M5119</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2016-09-27T12:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301013#M5120</link>
      <description>&lt;P&gt;well this is exactly what it says trying to open the excel document. i cant thank everybody enough for their timely responses. i have tried almost everything people have suggested in this post. this was the last piece of code i used (still getting same error):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*ProcessBody;
data _null_;

rc = stpsrv_header('Content-type','application/vnd.ms-excel');
  
rc = stpsrv_header('Content-disposition','attachment; filename=CL_Claims.xlsx');
  
run;

%let _ODSDEST=TAGSETS.MSOFFICE2K;    
%let _ODSSTYLE=seaside;

/* Create output */
%stpbegin;

  proc print data=VA_WORK.WRK_TEST_GL_CLAIMS;
  run;

%stpend;


*  Begin EG generated code (do not edit this line);
;*';*";*/;quit;
%STPEND;

*  End EG generated code (do not edit this line);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I believed this would be so much easier&amp;nbsp;&lt;img id="catsad" class="emoticon emoticon-catsad" src="https://communities.sas.com/i/smilies/16x16_cat-sad.png" alt="Cat Sad" title="Cat Sad" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 12:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301013#M5120</guid>
      <dc:creator>GeorgeGiannako</dc:creator>
      <dc:date>2016-09-27T12:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301014#M5121</link>
      <description>&lt;P&gt;The tagsets.ExcelXP destination creates XML content so you need to use &lt;FONT face="courier new,courier"&gt;.xml&lt;/FONT&gt; in the STPSRV_HEADER call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The tagsets.MSOffice2K destination creates HTML content so you need to use &lt;FONT face="courier new,courier"&gt;.htm&lt;/FONT&gt; in the STPSRV_HEADER call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a Microsoft limitation; they require the extension to match the content of the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Vince DelGobbo&lt;/P&gt;
&lt;P&gt;SAS R&amp;amp;D&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 12:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301014#M5121</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2016-09-27T12:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Export excel using stored process</title>
      <link>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301018#M5122</link>
      <description>&lt;P&gt;My gosh, i changed to htm using&amp;nbsp;&lt;SPAN&gt;tagsets.MSOffice2K and it worked! Now I only need to change to actual excel output (and maybe change the font, because the greek alphabet appears gibberish).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 13:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Export-excel-using-stored-process/m-p/301018#M5122</guid>
      <dc:creator>GeorgeGiannako</dc:creator>
      <dc:date>2016-09-27T13:27:12Z</dc:date>
    </item>
  </channel>
</rss>

