<?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 Dataset to Excel sheets? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/618#M301</link>
    <description>Hi everyone,&lt;BR /&gt;
I am not sure about the right forum but...&lt;BR /&gt;
&lt;BR /&gt;
I have a problem problem and I would be thankful if somebody can solve this.&lt;BR /&gt;
&lt;BR /&gt;
I have dataset like this...&lt;BR /&gt;
&lt;BR /&gt;
DOCTOR        PATIENT        &lt;BR /&gt;
Ann           Mark&lt;BR /&gt;
John          Anton&lt;BR /&gt;
Ann           Jeff&lt;BR /&gt;
Ann           James&lt;BR /&gt;
John          Howard&lt;BR /&gt;
William       Cliff&lt;BR /&gt;
.             .&lt;BR /&gt;
.             .&lt;BR /&gt;
.             .&lt;BR /&gt;
&lt;BR /&gt;
And I should export this dataset to different excel files by using keyvariable DOCTOR like this...&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\Ann.xls" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\William.xls" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\John.xls" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\xxxx.xls" DBMS=EXCEL2000 REPLACE;       &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Can I use some kind of macro or something? The dataset is so large that I cannot use handjob...&lt;BR /&gt;
&lt;BR /&gt;
Thank you for advance!</description>
    <pubDate>Thu, 11 May 2006 11:10:24 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2006-05-11T11:10:24Z</dc:date>
    <item>
      <title>Dataset to Excel sheets?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/618#M301</link>
      <description>Hi everyone,&lt;BR /&gt;
I am not sure about the right forum but...&lt;BR /&gt;
&lt;BR /&gt;
I have a problem problem and I would be thankful if somebody can solve this.&lt;BR /&gt;
&lt;BR /&gt;
I have dataset like this...&lt;BR /&gt;
&lt;BR /&gt;
DOCTOR        PATIENT        &lt;BR /&gt;
Ann           Mark&lt;BR /&gt;
John          Anton&lt;BR /&gt;
Ann           Jeff&lt;BR /&gt;
Ann           James&lt;BR /&gt;
John          Howard&lt;BR /&gt;
William       Cliff&lt;BR /&gt;
.             .&lt;BR /&gt;
.             .&lt;BR /&gt;
.             .&lt;BR /&gt;
&lt;BR /&gt;
And I should export this dataset to different excel files by using keyvariable DOCTOR like this...&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\Ann.xls" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\William.xls" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\John.xls" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
PROC EXPORT DATA=doctorset&lt;BR /&gt;
OUTFILE="c:\data\xxxx.xls" DBMS=EXCEL2000 REPLACE;       &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Can I use some kind of macro or something? The dataset is so large that I cannot use handjob...&lt;BR /&gt;
&lt;BR /&gt;
Thank you for advance!</description>
      <pubDate>Thu, 11 May 2006 11:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/618#M301</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-05-11T11:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset to Excel sheets?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/619#M302</link>
      <description>You could use the below macro to do this. It creates a list of macro variables from the variable doctor and loops through the PROC EXPORT statements. The value of doctor is resolved in both the WHERE= data set option as well as the OUTFILE=option. &lt;BR /&gt;
&lt;BR /&gt;
You might also want to take a look at the ExcelXP tagset which allows you to generate multiple worksheets based on the by value as well. See the below for more information on this.&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/base/topics/odsmarkup/" target="_blank"&gt;http://support.sas.com/rnd/base/topics/odsmarkup/&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ex1.                                                        &lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
 input  DOCTOR $ PATIENT $;&lt;BR /&gt;
cards;&lt;BR /&gt;
Ann Mark&lt;BR /&gt;
John Anton&lt;BR /&gt;
Ann Jeff&lt;BR /&gt;
Ann James&lt;BR /&gt;
John Howard&lt;BR /&gt;
William Cliff&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* Create a list of macro variables */&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
     select count(distinct doctor) into :last&lt;BR /&gt;
            from one;&lt;BR /&gt;
&lt;BR /&gt;
     select distinct(doctor) into: val1- :val%left(&amp;amp;last)&lt;BR /&gt;
            from one;&lt;BR /&gt;
   run;&lt;BR /&gt;
   quit;&lt;BR /&gt;
&lt;BR /&gt;
%macro loopit;&lt;BR /&gt;
  %do i=1 %to &amp;amp;last;&lt;BR /&gt;
&lt;BR /&gt;
    PROC EXPORT DATA=one(where=(doctor="&amp;amp;&amp;amp;val&amp;amp;i"))&lt;BR /&gt;
    OUTFILE="c:\data\&amp;amp;&amp;amp;val&amp;amp;i" DBMS=EXCEL2000 REPLACE;&lt;BR /&gt;
&lt;BR /&gt;
   run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend;&lt;BR /&gt;
%loopit&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ex2.&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
 input  DOCTOR $ PATIENT $;&lt;BR /&gt;
cards;&lt;BR /&gt;
Ann Mark&lt;BR /&gt;
John Anton&lt;BR /&gt;
Ann Jeff&lt;BR /&gt;
Ann James&lt;BR /&gt;
John Howard&lt;BR /&gt;
William Cliff&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=one;&lt;BR /&gt;
by doctor;&lt;BR /&gt;
run;&lt;BR /&gt;
ods tagsets.excelxp file="temp.xls";&lt;BR /&gt;
&lt;BR /&gt;
proc print data=one;&lt;BR /&gt;
by doctor;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods tagsets.excelxp close;</description>
      <pubDate>Thu, 11 May 2006 14:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/619#M302</guid>
      <dc:creator>Chevell_sas</dc:creator>
      <dc:date>2006-05-11T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset to Excel sheets?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/620#M303</link>
      <description>Thank you Chevell!

&lt;BR /&gt;
Message was edited by: IlariSAS at May 12, 2006 2:14 AM&lt;BR /&gt;</description>
      <pubDate>Fri, 12 May 2006 06:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Dataset-to-Excel-sheets/m-p/620#M303</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-05-12T06:14:14Z</dc:date>
    </item>
  </channel>
</rss>

