<?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: Stored Process - output to XLSX in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363065#M5406</link>
    <description>&lt;P&gt;It might be due to the lack of your encoding = 'UTF-8' on your second _webout&lt;/P&gt;
&lt;P&gt;I'm guessing that as a result you may be mixing encodings and you end up writing out characters in your value= statement that don't exist in the "default" encoding.&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2017 13:35:47 GMT</pubDate>
    <dc:creator>DavidPope</dc:creator>
    <dc:date>2017-05-31T13:35:47Z</dc:date>
    <item>
      <title>Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/362996#M5405</link>
      <description>&lt;P&gt;Hi. Now I need help. I am running two kinds of StP, Stand alone and Chained. In both types I want the Proc Report to make a XLSX output.&lt;/P&gt;&lt;P&gt;When&amp;nbsp;I run the Stand alone StP, I get my XLSX output and I can open it without any errormessages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I run the Chained StP, the XLSX is produced, but when I try to open it, I get en error message which tells me that the XLSX file contains unreadable contents. Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For&amp;nbsp;the test, in both StPs I make the output from sashelp.class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My codes&amp;nbsp;are shown below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Stand alone StP - this works :*/
%global OUTPUT;

*ProcessBody;

%MACRO Eksport;

%if &amp;amp;Output. = EXCEL %then %do;

	data _null_;
		rc = stpsrv_header('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

		rc = stpsrv_header('Content-disposition','attachment; filename=Test.xlsx');
	Run;
%End;
%Mend
%Eksport;

%Macro Print;
%if &amp;amp;Output. = EXCEL %then %do;

	ods excel file = _webout style=Plateau
		options (Sheet_label="IK"
					embedded_titles="yes"
					embed_titles_once="no");

	Title color=green "Test";
	proc print label data=sashelp.class noobs
		style (header) =[background=aliceblue]
		style (column) = [font_size=1.5];
	run;
	ods excel close;
%End;
%Mend;
%Print;

/*Chained StP - this does not work for XLSX, but it works for HTML-output:
The MAIN StP:*/

%global Output;

*ProcessBody;

%macro PUTMENU;

data _null_;
	file _webout encoding='UTF-8';
	put "&amp;lt;h1 style=color:ForestGreen align=center&amp;gt; Test of XLSX output";
	put "&amp;lt;/h1&amp;gt;";
	put "&amp;lt;div Align=Center&amp;gt;";
	put "&amp;lt;body&amp;gt;";
	put "&amp;lt;form ACTION='&amp;amp;_URL'&amp;gt;";
	put "&amp;lt;input TYPE='HIDDEN' NAME='_action' value='form,properties,execute,nobanner,newwindow'&amp;gt;";
	put "&amp;lt;input TYPE='hidden' NAME='_program' VALUE='&amp;amp;_Program._Print'&amp;gt;";

	put "&amp;lt;table BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH='30%'&amp;gt;";
	put "&amp;lt;tr BGCOLOR='ForestGreen'&amp;gt;";
run;

data _null_;
	file _webout;
	put "&amp;lt;/select&amp;gt;";
	put "&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;lt;P&amp;gt;";
	put "&amp;lt;input type='SUBMIT' name='valg' value='HTML'&amp;gt;";
	put "&amp;lt;input type='SUBMIT' name='valg' value='EXCEL'&amp;gt;";
	put "&amp;lt;input type='RESET' value='Tøm meny'&amp;gt;";
	put "&amp;lt;/body&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/html&amp;gt;";
run;

%Mend;
%PutMenu;

/*The Evoked StP:*/

%global Output;

*ProcessBody;

%MACRO Eksport;

	%if &amp;amp;Output. = EXCEL %then %do;

		ods excel file = _webout;

		data _null_;

		rc = stpsrv_header('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

		rc = stpsrv_header('Content-disposition','attachment; filename=Interne konti med siste transaksjon.xlsx');
		  
		run;	
	%end;
%Mend;
%Eksport;

%Macro Print;

%If &amp;amp;Output. = EXCEL %Then %Do;

	Proc print noobs label data=sashelp.class;

	Run;

	ODS Excel close;

%end;
%Mend;
%Print;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AMUMOR&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 10:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/362996#M5405</guid>
      <dc:creator>AMUMOR_SAS</dc:creator>
      <dc:date>2017-05-31T10:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363065#M5406</link>
      <description>&lt;P&gt;It might be due to the lack of your encoding = 'UTF-8' on your second _webout&lt;/P&gt;
&lt;P&gt;I'm guessing that as a result you may be mixing encodings and you end up writing out characters in your value= statement that don't exist in the "default" encoding.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 13:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363065#M5406</guid>
      <dc:creator>DavidPope</dc:creator>
      <dc:date>2017-05-31T13:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363178#M5407</link>
      <description>&lt;P&gt;Hi, and thank you for&amp;nbsp;your Reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you mean that I simply write like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ODS Excel file = _webout encoding='UTF-8';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Morten Fredrik&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363178#M5407</guid>
      <dc:creator>AMUMOR_SAS</dc:creator>
      <dc:date>2017-05-31T18:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363181#M5408</link>
      <description>&lt;P&gt;No, what I thought would help would be adding the encoding="UTF-8" to your second&lt;/P&gt;
&lt;P&gt;data null;&lt;/P&gt;
&lt;P&gt;just like the one on your first _webout in your first data null; block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363181#M5408</guid>
      <dc:creator>DavidPope</dc:creator>
      <dc:date>2017-05-31T18:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363182#M5409</link>
      <description>&lt;P&gt;Thank's, but it did not&amp;nbsp;help. I get the same message when I try to open the Excel File. Sorry.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363182#M5409</guid>
      <dc:creator>AMUMOR_SAS</dc:creator>
      <dc:date>2017-05-31T18:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363188#M5410</link>
      <description>&lt;P&gt;One other suggestions would be to change the name of your second .xlsx file to not include spaces so Test2.xlsx&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363188#M5410</guid>
      <dc:creator>DavidPope</dc:creator>
      <dc:date>2017-05-31T19:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363190#M5411</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have solved it. I had a dummy macro at the bottom of my Stp which I deliberately&amp;nbsp;envoked without having the "%" preceding the macro name, just to get a debug list. When I ran the StP to get Excel output, the debug log was placed in the Excel file and caused the error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Morten Fredrik&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363190#M5411</guid>
      <dc:creator>AMUMOR_SAS</dc:creator>
      <dc:date>2017-05-31T19:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to XLSX</title>
      <link>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363191#M5412</link>
      <description>&lt;P&gt;Morten - glad you resolved it and shared the solution on the board too.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-Process-output-to-XLSX/m-p/363191#M5412</guid>
      <dc:creator>DavidPope</dc:creator>
      <dc:date>2017-05-31T19:24:28Z</dc:date>
    </item>
  </channel>
</rss>

