<?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: How to create Two output in excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/345597#M79513</link>
    <description>&lt;P&gt;I don't think anyone has responded because SAS doesn't have a direct way of doing what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, three of us who often respond here created a macro that I think does exactly what you want. You can download the macro (there is no charge) at:&amp;nbsp;&lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code I just tested to do what I think you are trying to do. Of course, it won't run as is unless you already have a directory 'c:\art' established and have run the exportxl macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
  length question 4 choice $35 comment $200;
  retain question choice comment;
  input question choice$ 6-27 comment$ 28-55;
  cards;
1001 Administrator
1001 Administrator
1001 Administrator
1001 Administrator
1001 Coordinator
1001 Coordinator
1001 Coordinator
1001 Coordinator
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Manager
1001 Manager
1001 Other(please specify) Hiring Supervisor.
1001 Other(please specify) Hiring SV.
1001 Other(please specify) I was a hiring supervisor.
1001 Other(please specify) Hiring Manager.
1001 Other(please specify) Hiring Supervisor.
;

proc freq data=test;
  tables choice/ out=need1;
run;

data _null_;
  set need1 nobs=nobs;
  nobs+3;
  if _n_ eq 1 then call symput('nobs',catt('A',nobs));
  stop;
run;
%put &amp;amp;nobs.;

data need2 (keep=comment);
  set test (where=(not missing(comment)));
run;

%exportxl( data=need1,
           outfile=c:\art\testcombo.xlsx,
           sheet=test)

%exportxl( data=need2,
           outfile=c:\art\testcombo.xlsx,
           type=M,
           range=&amp;amp;nobs,
           sheet=test)
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2017 00:37:15 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-03-30T00:37:15Z</dc:date>
    <item>
      <title>How to create Two output in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/345431#M79469</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Dear EXPERTS,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;i WANT TO CREATE AN EXCEL OUT PUT&amp;nbsp;WITH PERCENTAGES AND COMMENTS UNDERNEATH.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;HERE IS THE SAMPLE DATASET&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; question &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; choice $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;35&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; comment $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;200&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;retain&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; question choice comment;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; question choice$ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;27&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; comment$ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;29&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;55&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1001 Administrator&lt;/P&gt;&lt;P&gt;1001 Administrator&lt;/P&gt;&lt;P&gt;1001 Administrator&lt;/P&gt;&lt;P&gt;1001 Administrator&lt;/P&gt;&lt;P&gt;1001 Coordinator&lt;/P&gt;&lt;P&gt;1001 Coordinator&lt;/P&gt;&lt;P&gt;1001 Coordinator&lt;/P&gt;&lt;P&gt;1001 Coordinator&lt;/P&gt;&lt;P&gt;1001 Supervisor&lt;/P&gt;&lt;P&gt;1001 Supervisor&lt;/P&gt;&lt;P&gt;1001 Supervisor&lt;/P&gt;&lt;P&gt;1001 Supervisor&lt;/P&gt;&lt;P&gt;1001 Supervisor&lt;/P&gt;&lt;P&gt;1001 Supervisor&lt;/P&gt;&lt;P&gt;1001 Manager&lt;/P&gt;&lt;P&gt;1001 Manager&lt;/P&gt;&lt;P&gt;1001 Other(please specify) Hiring Supervisor.&lt;/P&gt;&lt;P&gt;1001 Other(please specify) Hiring SV.&lt;/P&gt;&lt;P&gt;1001 Other(please specify) I was a hiring supervisor.&lt;/P&gt;&lt;P&gt;1001 Other(please specify) Hiring Manager.&lt;/P&gt;&lt;P&gt;1001 Other(please specify) Hiring Supervisor.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Desired output&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Questions#&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Choice Desc&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Numbers&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;percent&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;1001&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Administrator&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;19%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Coordinator&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;19%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Supervisor&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;29%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Manager&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Other (please specify)&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;23%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Total Response&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;U&gt;Comments&lt;/U&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Hiring Supervisor&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Hiring SV&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;I was a hiring supervisor.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Hiring Supervisor.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 15:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/345431#M79469</guid>
      <dc:creator>tekish</dc:creator>
      <dc:date>2017-03-29T15:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Two output in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/345597#M79513</link>
      <description>&lt;P&gt;I don't think anyone has responded because SAS doesn't have a direct way of doing what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, three of us who often respond here created a macro that I think does exactly what you want. You can download the macro (there is no charge) at:&amp;nbsp;&lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code I just tested to do what I think you are trying to do. Of course, it won't run as is unless you already have a directory 'c:\art' established and have run the exportxl macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
  length question 4 choice $35 comment $200;
  retain question choice comment;
  input question choice$ 6-27 comment$ 28-55;
  cards;
1001 Administrator
1001 Administrator
1001 Administrator
1001 Administrator
1001 Coordinator
1001 Coordinator
1001 Coordinator
1001 Coordinator
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Supervisor
1001 Manager
1001 Manager
1001 Other(please specify) Hiring Supervisor.
1001 Other(please specify) Hiring SV.
1001 Other(please specify) I was a hiring supervisor.
1001 Other(please specify) Hiring Manager.
1001 Other(please specify) Hiring Supervisor.
;

proc freq data=test;
  tables choice/ out=need1;
run;

data _null_;
  set need1 nobs=nobs;
  nobs+3;
  if _n_ eq 1 then call symput('nobs',catt('A',nobs));
  stop;
run;
%put &amp;amp;nobs.;

data need2 (keep=comment);
  set test (where=(not missing(comment)));
run;

%exportxl( data=need1,
           outfile=c:\art\testcombo.xlsx,
           sheet=test)

%exportxl( data=need2,
           outfile=c:\art\testcombo.xlsx,
           type=M,
           range=&amp;amp;nobs,
           sheet=test)
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 00:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/345597#M79513</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-30T00:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Two output in excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/496060#M131088</link>
      <description>&lt;P&gt;this is piece of SAS code that I use to control my output to Excel.&amp;nbsp; Not sure if this assist in your request, but maybe it has something in the EXCEL part that will.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* This macro creates a dataset with all the field's of the old dataset.
      A where claus is used to obtain only those records needed.
      The dataset is ordered by two fields.  */
%macro sqlcreat(olddata=,newtable=,wvar=,wvalue=,obone=,obtwo=);
   proc sql;
      create table &amp;amp;newtable. as
      select *
      from &amp;amp;olddata.
      where &amp;amp;wvar. = &amp;amp;wvalue.
      order by &amp;amp;obone., &amp;amp;obtwo.;
   quit;
%mend;
/* This macro will create a new dataset in a sorted order, or it will
      sort a dataset if the newset value is equal to the olddata value. */
%macro sortone(olddata=,newset=,byvar=);
   proc sort data=&amp;amp;olddata. out=&amp;amp;newset.;
      by &amp;amp;byvar.;
   run;
%mend;
/* This macro is used to merge a dataset named dummy (who's number of fields and
      records are equal to the largest number of possible result's for the 
      old dataset.) */
%macro mergeit(new_ds=,old_ds=,byvar=);
   data &amp;amp;new_ds.;
      merge dummy(in=in_t)
            &amp;amp;old_ds.(in=in_f);
      by &amp;amp;byvar.;
   run;
%mend;

options noxwait noxsync mlogic;
X "C:\Program Files\Microsoft Office\Office\EXCEL.EXE";
data _null_;
   x=sleep(5);
run;
filename cmds dde 'excel|system';
data _null_;
   length mystuff $250;
   file cmds;
   pre_book = '[open("'||"&amp;amp;temppath.\&amp;amp;workbook."||'")]';
   put pre_book;
run;
filename outpre dde
"Excel|&amp;amp;temppath.\[&amp;amp;workbook.]&amp;amp;sheet.!r1c1:r561c10" notab;

/* put the information into the cells in the worksheet */
data _null_;
   file outpre notab;
   put '09'x'09'x'09'x"&amp;amp;mytitle.";
   set head_date; /* contains the results in a SAS dataset */
   file outpre notab;
   put '09'x'09'x'09'xprt_month", " prt_year;
   put /* results from the macros output that is in datasets */;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 17:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Two-output-in-excel/m-p/496060#M131088</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-16T17:54:08Z</dc:date>
    </item>
  </channel>
</rss>

