<?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: output an Excel file with different tabs in a form in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958747#M374161</link>
    <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table3way;
  length dmtype durationbi $35;
  infile datalines dlm=',' dsd;
  input dmtype $ ordvar Durationbi $ Num cMean cSTD LowerCL UpperCL Prob_t;
return;
datalines;
"Type 1",1,"&amp;lt;=10 years",17,76.76,17.85,67.59,85.94,0.7243
"Type 1",2,"&amp;gt;10 year",44,75.30,13.06,71.32,79.27,0.7243
"Type 2 (*ESC*)n weqwqrqwer",1,"&amp;lt;=10 years",47,67.23,22.22,44.44,88.88,0.5584
"Type 2 (*ESC*)n weqwqrqwer",2,"&amp;gt;10 year",35,69.43,33.33,55.55,99.99,0.5584
;
run;

ods excel file="c:\temp\spantest.xlsx"   ;

title 'How to span Header Rows amd Data Rpws with RWI and DATA step';
data _null_; 
  set table3way end=last; 
  by dmtype;
  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
      obj.head_start(); 
	  ** Header row 1;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Type ", row_span:2, column_span: 1, style_attr:"vjust=m color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "Results", column_span:7, style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
	  ** Header row 2;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Durationbi", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "num", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cmean", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cstd", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "lowercl",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "uppercl", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "probt",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
  ** treat dmtype and prob_t differently so they span rows;

      obj.row_start(); 
	  if first.dmtype then do;
         obj.format_cell(data: dmtype,row_span:2, style_attr:"vjust=m fontweight=bold" ); 
	  end;
      obj.format_cell(data: Durationbi, row_span:1); 
      obj.format_cell(data: num, row_span:1); 
      obj.format_cell(data: cmean, row_span:1); 
      obj.format_cell(data: cstd, row_span:1); 
      obj.format_cell(data: lowercl, row_span:1); 
      obj.format_cell(data: uppercl, row_span:1); 
	  if first.dmtype then do;
         obj.format_cell(data: prob_t, row_span:2, style_attr:"vjust=m fontweight=bold"); 
	  end;
      obj.row_end(); 
   
  if last then do; 
      obj.table_end(); 
    end; 
run;
footnote;title;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1738999138103.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104499i46FDE31F578B36DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1738999138103.png" alt="Ksharp_0-1738999138103.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Feb 2025 07:19:04 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-02-08T07:19:04Z</dc:date>
    <item>
      <title>output an Excel file with different tabs in a form</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958622#M374133</link>
      <description>&lt;P&gt;&lt;SPAN class="Y2IQFc"&gt;Hello everyone,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Y2IQFc"&gt; how can I output an Excel file with different tabs and with data in the cells&amp;nbsp; in SAS? Thank you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hoibai_0-1738923650794.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104445iD6882E6269F49294/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hoibai_0-1738923650794.png" alt="Hoibai_0-1738923650794.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 10:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958622#M374133</guid>
      <dc:creator>Hoibai</dc:creator>
      <dc:date>2025-02-07T10:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: output an Excel file with different tabs in a form</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958626#M374134</link>
      <description>&lt;P&gt;We need to see (a portion of) the actual SAS data set you will use, otherwise this is impossible to answer. Please show us the SAS data set you are using as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;). Do NOT show us the SAS data set in an Excel file; do NOT show us data as copy and pasted from Excel; do NOT show us the SAS data set in any other way, except as shown at the link.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 10:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958626#M374134</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-07T10:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: output an Excel file with different tabs in a form</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958708#M374149</link>
      <description>&lt;P&gt;Filling specific cells in an Excel form directly from SAS is not usually possible. A good solution is to have SAS populate a tab of just columns and rows, then have an Excel macro that copies the required data to the right form cells.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use PROC EXPORT to populate a tab with column and rows from a SAS dataset. Then the Excel macro is run fill out the pre-designed form.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 20:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958708#M374149</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-02-07T20:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: output an Excel file with different tabs in a form</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958747#M374161</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table3way;
  length dmtype durationbi $35;
  infile datalines dlm=',' dsd;
  input dmtype $ ordvar Durationbi $ Num cMean cSTD LowerCL UpperCL Prob_t;
return;
datalines;
"Type 1",1,"&amp;lt;=10 years",17,76.76,17.85,67.59,85.94,0.7243
"Type 1",2,"&amp;gt;10 year",44,75.30,13.06,71.32,79.27,0.7243
"Type 2 (*ESC*)n weqwqrqwer",1,"&amp;lt;=10 years",47,67.23,22.22,44.44,88.88,0.5584
"Type 2 (*ESC*)n weqwqrqwer",2,"&amp;gt;10 year",35,69.43,33.33,55.55,99.99,0.5584
;
run;

ods excel file="c:\temp\spantest.xlsx"   ;

title 'How to span Header Rows amd Data Rpws with RWI and DATA step';
data _null_; 
  set table3way end=last; 
  by dmtype;
  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
      obj.head_start(); 
	  ** Header row 1;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Type ", row_span:2, column_span: 1, style_attr:"vjust=m color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "Results", column_span:7, style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
	  ** Header row 2;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Durationbi", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "num", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cmean", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cstd", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "lowercl",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "uppercl", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "probt",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
  ** treat dmtype and prob_t differently so they span rows;

      obj.row_start(); 
	  if first.dmtype then do;
         obj.format_cell(data: dmtype,row_span:2, style_attr:"vjust=m fontweight=bold" ); 
	  end;
      obj.format_cell(data: Durationbi, row_span:1); 
      obj.format_cell(data: num, row_span:1); 
      obj.format_cell(data: cmean, row_span:1); 
      obj.format_cell(data: cstd, row_span:1); 
      obj.format_cell(data: lowercl, row_span:1); 
      obj.format_cell(data: uppercl, row_span:1); 
	  if first.dmtype then do;
         obj.format_cell(data: prob_t, row_span:2, style_attr:"vjust=m fontweight=bold"); 
	  end;
      obj.row_end(); 
   
  if last then do; 
      obj.table_end(); 
    end; 
run;
footnote;title;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1738999138103.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104499i46FDE31F578B36DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1738999138103.png" alt="Ksharp_0-1738999138103.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2025 07:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-an-Excel-file-with-different-tabs-in-a-form/m-p/958747#M374161</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-08T07:19:04Z</dc:date>
    </item>
  </channel>
</rss>

