<?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: Sas Web application Stored Procedure in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745081#M233523</link>
    <description>&lt;P&gt;I've written web based applications like this in the past that generate / download to the browser Excel workbooks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume that when you say "Stored Procedure", you mean SAS Stored Process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I don't know if I'm over simplifying things, but I read your question is about how to write 3 tables to three different worksheets in excel.... and this doesn't really have anything to do with the stored process or web output that's wrapped around the Excel workbook creation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I've simplified your problem and come up with this simple code. This code creates three test datasets, then uses similar code to what you have. Rather than send this to _webout, I send this to a file on disk.&lt;/P&gt;
&lt;P&gt;Run this test in EG:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* create 3 test data sets;&lt;BR /&gt;data one(where=(age=12))&lt;BR /&gt;two(where=(age=13))&lt;BR /&gt;three(where=(age=14));&lt;/P&gt;
&lt;P&gt;set sashelp.class;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;*create workbook&lt;BR /&gt;ods excel file = "D:\excel.xlsx" ;&lt;BR /&gt;ods excel style = Plateau;&lt;BR /&gt;ods excel options(sheet_name= "12 year olds");&lt;/P&gt;
&lt;P&gt;proc print noobs data=one; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "13 year olds");&lt;/P&gt;
&lt;P&gt;proc print noobs data=two; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "14 year olds");&lt;BR /&gt;proc print noobs data=three; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And running that generates an excel workbook with three worksheets, one for each table and these are labeled.&lt;/P&gt;
&lt;P&gt;If you now drop that code into your stored process, then it should work in your web app.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Excel.png" style="width: 590px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59945i7CE6F55553C71C6E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Excel.png" alt="Excel.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jun 2021 05:23:09 GMT</pubDate>
    <dc:creator>MarkBodt_NZ</dc:creator>
    <dc:date>2021-06-02T05:23:09Z</dc:date>
    <item>
      <title>Sas Web application Stored Procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/744769#M233365</link>
      <description>&lt;P&gt;In web application STP i have parameter that refer to excel check box. İf this parameter is greater than 0 (it means excel chekckbox selected) i want to write 3 table in excel in 3 different sheet and user can download it from browser automatically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current code below and it works but works for only 1 table. How can i make an excel output from 3 different tables?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%global excel;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%if %length(&amp;amp;excel) ne 0 %then %do;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;rc = stpsrv_header('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');&lt;BR /&gt;rc = stpsrv_header('Content-disposition','attachment; filename=test.xlsx');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods excel file = _webout ;&lt;BR /&gt;ods excel style = Plateau;&lt;/P&gt;&lt;P&gt;proc print noobs data=work.table1; run;&lt;/P&gt;&lt;P&gt;ods excel close;&lt;/P&gt;&lt;P&gt;%end; /* in this do end block; i wanna make an excel file from work.table1 work.table2 and work.table3*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%else %do;&lt;BR /&gt;%STPBEGIN;&lt;BR /&gt;proc print data=work.table1;run;&lt;/P&gt;&lt;P&gt;%STPEND;&lt;BR /&gt;%end;&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2021 12:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/744769#M233365</guid>
      <dc:creator>uguraltuntas67</dc:creator>
      <dc:date>2021-05-31T12:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Web application Stored Procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745081#M233523</link>
      <description>&lt;P&gt;I've written web based applications like this in the past that generate / download to the browser Excel workbooks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume that when you say "Stored Procedure", you mean SAS Stored Process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I don't know if I'm over simplifying things, but I read your question is about how to write 3 tables to three different worksheets in excel.... and this doesn't really have anything to do with the stored process or web output that's wrapped around the Excel workbook creation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I've simplified your problem and come up with this simple code. This code creates three test datasets, then uses similar code to what you have. Rather than send this to _webout, I send this to a file on disk.&lt;/P&gt;
&lt;P&gt;Run this test in EG:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* create 3 test data sets;&lt;BR /&gt;data one(where=(age=12))&lt;BR /&gt;two(where=(age=13))&lt;BR /&gt;three(where=(age=14));&lt;/P&gt;
&lt;P&gt;set sashelp.class;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;*create workbook&lt;BR /&gt;ods excel file = "D:\excel.xlsx" ;&lt;BR /&gt;ods excel style = Plateau;&lt;BR /&gt;ods excel options(sheet_name= "12 year olds");&lt;/P&gt;
&lt;P&gt;proc print noobs data=one; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "13 year olds");&lt;/P&gt;
&lt;P&gt;proc print noobs data=two; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "14 year olds");&lt;BR /&gt;proc print noobs data=three; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And running that generates an excel workbook with three worksheets, one for each table and these are labeled.&lt;/P&gt;
&lt;P&gt;If you now drop that code into your stored process, then it should work in your web app.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Excel.png" style="width: 590px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59945i7CE6F55553C71C6E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Excel.png" alt="Excel.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 05:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745081#M233523</guid>
      <dc:creator>MarkBodt_NZ</dc:creator>
      <dc:date>2021-06-02T05:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Web application Stored Procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745112#M233533</link>
      <description>&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your kindly reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can create an excel on file disk but the problem is i can get many request in the same time and each excel possibly consist of different rows of data.&lt;/P&gt;&lt;P&gt;So i've tried to create a temporary excel on file disk under the user session bu i can not send to _webout that excel.&lt;/P&gt;&lt;P&gt;This is why excel should be downloandable on browser if user want.&lt;/P&gt;&lt;P&gt;I am not sure that creating an excel from multiple table and sending to _webout is even possible. I could not find any document or post online.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 09:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745112#M233533</guid>
      <dc:creator>uguraltuntas67</dc:creator>
      <dc:date>2021-06-02T09:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Web application Stored Procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745330#M233600</link>
      <description>&lt;P&gt;Actually, it does all work if yuo prepare the code properly for a stored process web app.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my post I was trying to get across that the best way to troubleshoot this problem (and develop the application) is to simplify everything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is, get it all working in EG first before wrapping it in a stored process / web app.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your problem was around not being able to create an excel workbook with multiple tabs for different tables. So I got this working for you in EG.&lt;/P&gt;
&lt;P&gt;Now that that's working, you need to prepare the code and for the stored process / web app, like you've done for the original app that you have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And one of those preparation steps is changing the file destination from disk to _webout&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the proof. I've prepared my code and put it into a stored process and executed the stored process in the Stored Process WebApp:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CAS_43.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59984iC599FC5F0A81ACB5/image-size/large?v=v2&amp;amp;px=999" role="button" title="CAS_43.png" alt="CAS_43.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; And here's the code I put into the stored process:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*ProcessBody;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rc = stpsrv_header('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');&lt;/P&gt;
&lt;P&gt;rc = stpsrv_header('Content-disposition','attachment; filename=test.xlsx');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* create 3 test data sets;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; one(where=(age=&lt;STRONG&gt;12&lt;/STRONG&gt;))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; two(where=(age=&lt;STRONG&gt;13&lt;/STRONG&gt;))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; three(where=(age=&lt;STRONG&gt;14&lt;/STRONG&gt;));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*create workbook;&lt;/P&gt;
&lt;P&gt;ods excel file = _webout;&lt;/P&gt;
&lt;P&gt;ods excel style = Plateau;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "12 year olds");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt; noobs data=one;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "13 year olds");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt; noobs data=two;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods excel options(sheet_name= "14 year olds");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt; noobs data=three;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 21:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-Web-application-Stored-Procedure/m-p/745330#M233600</guid>
      <dc:creator>MarkBodt_NZ</dc:creator>
      <dc:date>2021-06-02T21:22:28Z</dc:date>
    </item>
  </channel>
</rss>

