<?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: Juletip #15 - SAS and advanced Excel in SAS Community Nordic</title>
    <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-15-SAS-and-advanced-Excel/m-p/320375#M29</link>
    <description>&lt;P&gt;A very cool tip! I wasn't aware of all the features of the&amp;nbsp;tableEditor-tagset. Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24997"&gt;@OleSteen&lt;/a&gt;,&amp;nbsp;you've just made it harder for me to pick my favourite Juletip. &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt; This is a strong contender!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Share your favourite with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13642"&gt;@GertNissen&lt;/a&gt;&amp;nbsp;at&amp;nbsp;&lt;A href="https://www.linkedin.com/pulse/more-sas-tips-which-your-favorite-gert-nissen" target="_blank"&gt;https://www.linkedin.com/pulse/more-sas-tips-which-your-favorite-gert-nissen&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2016 22:13:32 GMT</pubDate>
    <dc:creator>MichelleHomes</dc:creator>
    <dc:date>2016-12-20T22:13:32Z</dc:date>
    <item>
      <title>Juletip #15 - SAS and advanced Excel</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-15-SAS-and-advanced-Excel/m-p/320368#M28</link>
      <description>&lt;P&gt;Can't wait to send this "Juletip" - so here you are&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you know that it's possible to create quite powerfull Excel-files using SAS.&lt;BR /&gt;In the below example I have tried some of the functionalities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First I create a sample-data, based on the wellknown SASHELP.CLASS, and then I use a simple ODS EXCEL statement to create a Sheet with the content of this table; Just to show that it is possible to use formulas, I have the height shown as both digits, and as bars using a REPT-funktion in Excel.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Then I create a new Sheet using the new PROC MSCHART procedure, to show that it is possible to create true Excel charts from SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally I use the tableEditor-tagset to create a JavaScript that automatically generates an Excel Pivot-table based on the first Sheet&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Try it out, and you might be surprised of the funtionality, and might be inspired to try more by yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read more about tableEditor-tagset here:&lt;BR /&gt;&lt;A href="http://support.sas.com/rnd/base/ods/odsmarkup/tableeditor/" target="_blank"&gt;http://support.sas.com/rnd/base/ods/odsmarkup/tableeditor/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy holiday.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Path = C:\Temp;  /* Path for results */
%let File = Test;     /* Name of both XLSX and JS file */

/* Don't automatically open results when generated */
ods noresults;

/* Create sample data based on SASHELP.CLASS */
/* Just to have more columns to deal with and see how formulas can be used */
data sample;
  set sashelp.class;
	select (sex);
    when ("F") do; Teacher = "Ms. Sophie Johnson"; Sport = "Handball"; end;
		when ("M") do; Teacher = "Mr. John Scmidt"; Sport = "Soccer"; end;
		otherwise;
	end;
  Formula = cats('=REPT("|", F',put(_N_+1,3.-L),')');
	Height = round(Height*2.54);
run;

/* Create the excelfile with data */
ods excel file="&amp;amp;path.\&amp;amp;file..xlsx" 
    style=HTMLBlue
    options (absolute_row_height='20' 
    absolute_column_width='20,10,10,10,10,10,30'
    sheet_name='Data' /* This name is used in the pivot-definition below */
    frozen_headers='on');

proc print data = sample noobs label;
var teacher sport sex age name height;
var formula / style={foreground=lightblue font_face='playbill'} 
              style(header)=Header;
label formula = "Height";
run;

ods excel options(sheet_name='Picture' frozen_headers='off');
proc sql;
  create table sample1 as
	select age, avg(height) as height format=comma8.
	from sample
	group by 1;
quit;
title "Average height by Age";
proc mschart data=sample1 category=age width=4in position="$C$1";
vcolumn height;
run;
title;

ods excel close;

/* Get template for tableEditor from support, and save in ODS path */
/* This could be done only once, by setting up ods path to a permanent library */
Filename tpl url "http://support.sas.com/rnd/base/ods/odsmarkup/tableeditor/tableeditor.tpl";
ods path(prepend) work.templates(update);
%include tpl;

/* Use tagset tableEditor, to create JavaScript which generates the Pivot-table */
ods tagsets.tableeditor file="&amp;amp;path.\&amp;amp;file..js"
  /* \ (backslash) converted to \\ because of JavaScript */
  options(update_target="%sysfunc(tranwrd(&amp;amp;path,\,\\))\\&amp;amp;file..xlsx"
	  default_file ="&amp;amp;path.\&amp;amp;file..xlsx"
    output_type="script"
    sheet_name="Data" /* Sheet-name from Excel */
    pivot_sheet_name="Pivot" /* Sheet-name for Pivot-table */
	  pivotpage="Teacher,Sport"
    pivotrow="Age,Name"
		pivotcol="Sex"
    pivotdata="Height" 
		pivotdata_stats="average"
		pivotdata_fmt="#,##0"
	  pivot_subtotal="no"
	  doc="help" /* Notice the documentation in the SAS-log */
		           /* Could be omitted in production */
);

/* Dummy-code for generating the JavaScript */
data _null_;
 file print;
 put "test";
run;

ods tagsets.tableeditor close;

/* Open the JavaScript-file, which generates the Pivot-table */
/* If running this code in Enterprise Guide, your administrator must set ALLOWXCMD 
   or you can get System Command Task for Enterprise Guide from support.sas.com */
x "&amp;amp;path.\&amp;amp;file..js";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Attached the generated Excel-file&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 21:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-15-SAS-and-advanced-Excel/m-p/320368#M28</guid>
      <dc:creator>OleSteen</dc:creator>
      <dc:date>2016-12-20T21:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Juletip #15 - SAS and advanced Excel</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-15-SAS-and-advanced-Excel/m-p/320375#M29</link>
      <description>&lt;P&gt;A very cool tip! I wasn't aware of all the features of the&amp;nbsp;tableEditor-tagset. Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24997"&gt;@OleSteen&lt;/a&gt;,&amp;nbsp;you've just made it harder for me to pick my favourite Juletip. &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt; This is a strong contender!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Share your favourite with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13642"&gt;@GertNissen&lt;/a&gt;&amp;nbsp;at&amp;nbsp;&lt;A href="https://www.linkedin.com/pulse/more-sas-tips-which-your-favorite-gert-nissen" target="_blank"&gt;https://www.linkedin.com/pulse/more-sas-tips-which-your-favorite-gert-nissen&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 22:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-15-SAS-and-advanced-Excel/m-p/320375#M29</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2016-12-20T22:13:32Z</dc:date>
    </item>
  </channel>
</rss>

