<?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 ODS tagsets.excelxp in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462582#M117793</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;In the insurance company where I work there are raw data tables that publish every month.&lt;/P&gt;&lt;P&gt;(For &amp;nbsp;example:&lt;SPAN&gt;Raw_1711 &amp;nbsp;is for NOV 2017)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Every month I need to use specific raw data files(determine be manager) and perform some summary statistics on them.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then I need to create an output summary report(one table) that contain information about the requested tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My manager ask me to automat export the summary tables +raw data tables to one excel file in multiple sheets.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My task is to create a flexible program that know to export it .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a problem with&amp;nbsp;ODS tagsets.excelxp &amp;nbsp;step .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please see the tables below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data Raw_1711;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;1 10.1&lt;BR /&gt;2 20&lt;BR /&gt;3 30&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1712;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;4 40&lt;BR /&gt;5 50&lt;BR /&gt;6 60&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1801;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;7 70&lt;BR /&gt;8 80&lt;BR /&gt;9 90&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1802;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;10 100&lt;BR /&gt;11 110&lt;BR /&gt;12 120&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1803;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;13 130&lt;BR /&gt;14 140&lt;BR /&gt;15 150&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1804;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;16 160&lt;BR /&gt;17 170.1&lt;BR /&gt;18 180.2&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1805;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;19 190&lt;BR /&gt;20 200.3&lt;BR /&gt;21 210&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let vector=1804+1803+1712;&lt;BR /&gt;%let k=3;&lt;BR /&gt;%put &amp;amp;vector.;&lt;/P&gt;&lt;P&gt;%macro Macro1;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;mon&amp;amp;i.=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;Call Symput("mon&amp;amp;i.",mon&amp;amp;i.);&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;Data _null_;&lt;BR /&gt;%Macro1;&lt;BR /&gt;Run;&lt;BR /&gt;%put &amp;amp;mon1.;&lt;BR /&gt;%put &amp;amp;mon2.;&lt;BR /&gt;%put &amp;amp;mon3.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Macro2;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;Data Mydata_&amp;amp;mon.;&lt;BR /&gt;SET Raw_&amp;amp;mon.(where=(int(y)=y));&lt;BR /&gt;Run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%Macro2;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Macro3;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;PROC SQL;&lt;BR /&gt;create table Summary&amp;amp;mon. as&lt;BR /&gt;select sum(y) as Sum_Y,&lt;BR /&gt;min(y) as Min_Y,&lt;BR /&gt;max(y) as Max_Y&lt;BR /&gt;from Mydata_&amp;amp;mon.&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%Macro3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Macro4;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;proc transpose data=Summary&amp;amp;mon.&lt;BR /&gt;prefix=Y_&amp;amp;mon.&lt;BR /&gt;out=Summary2_&amp;amp;mon.;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%Macro4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro Macro5;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;Summary2_&amp;amp;mon.&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;Data FinalOutput;&lt;BR /&gt;Merge %Macro5;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* My target is to use ODS tagsets.excelxp to export folloeing tables to excel*/&lt;BR /&gt;/*I want to have a flexible code that foe each user arguments in vector parameter&lt;BR /&gt;we will get automatic export to excel .Each table in a separate sheeet*/&lt;BR /&gt;proc print data=FinalOutput noobs;Run;&lt;BR /&gt;proc print data=Mydata_1804 noobs;Run;&lt;BR /&gt;proc print data=Mydata_1803 noobs;Run;&lt;BR /&gt;proc print data=Mydata_1712 noobs;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 May 2018 07:54:26 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-05-16T07:54:26Z</dc:date>
    <item>
      <title>ODS tagsets.excelxp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462582#M117793</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;In the insurance company where I work there are raw data tables that publish every month.&lt;/P&gt;&lt;P&gt;(For &amp;nbsp;example:&lt;SPAN&gt;Raw_1711 &amp;nbsp;is for NOV 2017)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Every month I need to use specific raw data files(determine be manager) and perform some summary statistics on them.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then I need to create an output summary report(one table) that contain information about the requested tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My manager ask me to automat export the summary tables +raw data tables to one excel file in multiple sheets.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My task is to create a flexible program that know to export it .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a problem with&amp;nbsp;ODS tagsets.excelxp &amp;nbsp;step .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please see the tables below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data Raw_1711;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;1 10.1&lt;BR /&gt;2 20&lt;BR /&gt;3 30&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1712;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;4 40&lt;BR /&gt;5 50&lt;BR /&gt;6 60&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1801;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;7 70&lt;BR /&gt;8 80&lt;BR /&gt;9 90&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1802;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;10 100&lt;BR /&gt;11 110&lt;BR /&gt;12 120&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1803;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;13 130&lt;BR /&gt;14 140&lt;BR /&gt;15 150&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1804;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;16 160&lt;BR /&gt;17 170.1&lt;BR /&gt;18 180.2&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;Data Raw_1805;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;19 190&lt;BR /&gt;20 200.3&lt;BR /&gt;21 210&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let vector=1804+1803+1712;&lt;BR /&gt;%let k=3;&lt;BR /&gt;%put &amp;amp;vector.;&lt;/P&gt;&lt;P&gt;%macro Macro1;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;mon&amp;amp;i.=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;Call Symput("mon&amp;amp;i.",mon&amp;amp;i.);&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;Data _null_;&lt;BR /&gt;%Macro1;&lt;BR /&gt;Run;&lt;BR /&gt;%put &amp;amp;mon1.;&lt;BR /&gt;%put &amp;amp;mon2.;&lt;BR /&gt;%put &amp;amp;mon3.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Macro2;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;Data Mydata_&amp;amp;mon.;&lt;BR /&gt;SET Raw_&amp;amp;mon.(where=(int(y)=y));&lt;BR /&gt;Run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%Macro2;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Macro3;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;PROC SQL;&lt;BR /&gt;create table Summary&amp;amp;mon. as&lt;BR /&gt;select sum(y) as Sum_Y,&lt;BR /&gt;min(y) as Min_Y,&lt;BR /&gt;max(y) as Max_Y&lt;BR /&gt;from Mydata_&amp;amp;mon.&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%Macro3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Macro4;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;proc transpose data=Summary&amp;amp;mon.&lt;BR /&gt;prefix=Y_&amp;amp;mon.&lt;BR /&gt;out=Summary2_&amp;amp;mon.;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%Macro4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro Macro5;&lt;BR /&gt;%DO i=1 %TO &amp;amp;k.;&lt;BR /&gt;%let mon=%scan(&amp;amp;vector.,&amp;amp;i.,+);&lt;BR /&gt;Summary2_&amp;amp;mon.&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;Data FinalOutput;&lt;BR /&gt;Merge %Macro5;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* My target is to use ODS tagsets.excelxp to export folloeing tables to excel*/&lt;BR /&gt;/*I want to have a flexible code that foe each user arguments in vector parameter&lt;BR /&gt;we will get automatic export to excel .Each table in a separate sheeet*/&lt;BR /&gt;proc print data=FinalOutput noobs;Run;&lt;BR /&gt;proc print data=Mydata_1804 noobs;Run;&lt;BR /&gt;proc print data=Mydata_1803 noobs;Run;&lt;BR /&gt;proc print data=Mydata_1712 noobs;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 07:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462582#M117793</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-05-16T07:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: ODS tagsets.excelxp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462595#M117795</link>
      <description>&lt;P&gt;Do you know what, there is at least 2 "better" methods of doing that which jump to mind without even looking at the code throughly.&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; Do you have SAS 9.4 (think that is the first)?&amp;nbsp; If so then it is far simpler as you can use the libname step:&lt;/P&gt;
&lt;PRE&gt;libname tmp xlsx "&amp;lt;path to file&amp;gt;/&amp;lt;filename&amp;gt;/xlsx";

proc copy in=work out=tmp;
  select raw_1711 raw_1712...;
run;

libname tmp clear;&lt;/PRE&gt;
&lt;P&gt;Notice once again how I manage to use the code window - its the {i} above the post area, so that code clearly stands out and retains the code formatting (and I don't use mixed case, and use indents etc.).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp; Put all the data you want to export into one directory/libname, then you can use the SAS metadata to generate your code quickly and simply without all the messy macro code which will fall over most of the time.&amp;nbsp; E.g. I put all the output data in a libname tmp.&lt;/P&gt;
&lt;PRE&gt;ods tagsets.excelxp file="&amp;lt;path&amp;gt;/&amp;lt;filename&amp;gt;.xlsx";

data _null_;
  set sashelp.vtable (where=(libname="TMP"));
  call execute('ods tagsets.excelxp options(sheet_name="'||strip(memname)||'");
                proc report data=tmp.'||strip(memname)||' nowd;  column _all_; run;');
run;&lt;BR /&gt;&lt;BR /&gt;ods tagsets.excelxp close;&lt;/PRE&gt;
&lt;P&gt;Now this uses a magically thing called datasteps and Base SAS programming.&amp;nbsp; The data _nul_ retrieves all the dataset names from the metadata in the given library and then for each of those, it creates a tab naming step and a proc report to output the data.&amp;nbsp; In this way you do not need looping, name lists, number of datasets etc.&amp;nbsp; Far simpler and more robust.&amp;nbsp; You could do the same with proc export rather than tagsets.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 08:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462595#M117795</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-16T08:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: ODS tagsets.excelxp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462603#M117802</link>
      <description>&lt;P&gt;As a first step, use a data step to determine the dataset names needed, and store them with call symput into a single macro variable.&lt;/P&gt;
&lt;P&gt;Then concatenate those datasets into one, using the indsname option to retrieve the originating dataset name that you keep in a new variable in the dataset. (see example 12 in &lt;A href="http://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p00hxg3x8lwivcn1f0e9axziw57y.htm&amp;amp;locale=de" target="_blank"&gt;SET Statement&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;From then on, you can use that variable for by-group processing in data/proc steps and for group by in SQL. NO further macro processing needed.&lt;/P&gt;
&lt;P&gt;In ODS, use the appropriate option to switch sheets along the group variable.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 08:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-tagsets-excelxp/m-p/462603#M117802</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-16T08:55:36Z</dc:date>
    </item>
  </channel>
</rss>

