<?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 Getting data totals and descriptive info in Excel output w/ proc export in Microsoft Integration with SAS</title>
    <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6419#M252</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Right now I create a data file in SAS, and I'm trying to show some summaries of the data (from different perspectives) so people can quickly determine if the data set is flawed in some way.  Here are two examples of the summaries I create:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table endsql1 as&lt;BR /&gt;
   select issyear,issmonth,aveissmonth,sum(count) as PolicyCount,sum(units) as Units,sum(amtinfrc) as AmountInforce,sum(statres) as StatReserve&lt;BR /&gt;
      from endmerge3&lt;BR /&gt;
   group by issyear,issmonth,aveissmonth;&lt;BR /&gt;
   quit;&lt;BR /&gt;
proc export data = endsql1&lt;BR /&gt;
   dbms = excel2000&lt;BR /&gt;
   outfile = "J:\Val\Japan\Ord\20&amp;amp;crntqtr.\Prodfiles\SAScode\Summaries\Ord\&amp;amp;inforcefilename.&amp;amp;valqtr.END.xls"&lt;BR /&gt;
   replace;&lt;BR /&gt;
   sheet = 'IssueDate';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table endsql2 as&lt;BR /&gt;
   select modelage,issage,sum(count) as PolicyCount,sum(units) as Units,sum(amtinfrc) as AmountInforce,sum(statres) as StatReserve&lt;BR /&gt;
      from endmerge3&lt;BR /&gt;
   group by modelage,issage;&lt;BR /&gt;
   quit;&lt;BR /&gt;
proc export data = endsql2&lt;BR /&gt;
   dbms = excel2000&lt;BR /&gt;
   outfile = "J:\Val\Japan\Ord\20&amp;amp;crntqtr.\Prodfiles\SAScode\Summaries\Ord\&amp;amp;inforcefilename.&amp;amp;valqtr.END.xls"&lt;BR /&gt;
   replace;&lt;BR /&gt;
   sheet = 'IssueAge';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I would like to include, on another tab of this spreadsheet, the name &amp;amp; location of the program that produced it.  Additionally, I would like these summaries to display totals of each data field on the last row.  Does anyone know of a way to code this into SAS?  I have searched for quite some time with no luck.  Thanks in advance!&lt;BR /&gt;
&lt;BR /&gt;
-Ken</description>
    <pubDate>Thu, 17 Jan 2008 19:05:17 GMT</pubDate>
    <dc:creator>Kenbutsu</dc:creator>
    <dc:date>2008-01-17T19:05:17Z</dc:date>
    <item>
      <title>Getting data totals and descriptive info in Excel output w/ proc export</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6419#M252</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Right now I create a data file in SAS, and I'm trying to show some summaries of the data (from different perspectives) so people can quickly determine if the data set is flawed in some way.  Here are two examples of the summaries I create:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table endsql1 as&lt;BR /&gt;
   select issyear,issmonth,aveissmonth,sum(count) as PolicyCount,sum(units) as Units,sum(amtinfrc) as AmountInforce,sum(statres) as StatReserve&lt;BR /&gt;
      from endmerge3&lt;BR /&gt;
   group by issyear,issmonth,aveissmonth;&lt;BR /&gt;
   quit;&lt;BR /&gt;
proc export data = endsql1&lt;BR /&gt;
   dbms = excel2000&lt;BR /&gt;
   outfile = "J:\Val\Japan\Ord\20&amp;amp;crntqtr.\Prodfiles\SAScode\Summaries\Ord\&amp;amp;inforcefilename.&amp;amp;valqtr.END.xls"&lt;BR /&gt;
   replace;&lt;BR /&gt;
   sheet = 'IssueDate';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table endsql2 as&lt;BR /&gt;
   select modelage,issage,sum(count) as PolicyCount,sum(units) as Units,sum(amtinfrc) as AmountInforce,sum(statres) as StatReserve&lt;BR /&gt;
      from endmerge3&lt;BR /&gt;
   group by modelage,issage;&lt;BR /&gt;
   quit;&lt;BR /&gt;
proc export data = endsql2&lt;BR /&gt;
   dbms = excel2000&lt;BR /&gt;
   outfile = "J:\Val\Japan\Ord\20&amp;amp;crntqtr.\Prodfiles\SAScode\Summaries\Ord\&amp;amp;inforcefilename.&amp;amp;valqtr.END.xls"&lt;BR /&gt;
   replace;&lt;BR /&gt;
   sheet = 'IssueAge';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I would like to include, on another tab of this spreadsheet, the name &amp;amp; location of the program that produced it.  Additionally, I would like these summaries to display totals of each data field on the last row.  Does anyone know of a way to code this into SAS?  I have searched for quite some time with no luck.  Thanks in advance!&lt;BR /&gt;
&lt;BR /&gt;
-Ken</description>
      <pubDate>Thu, 17 Jan 2008 19:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6419#M252</guid>
      <dc:creator>Kenbutsu</dc:creator>
      <dc:date>2008-01-17T19:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data totals and descriptive info in Excel output w/ proc export</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6420#M253</link>
      <description>Hi:&lt;BR /&gt;
  Here's one possible way to do it. Since you started with PROC EXPORT, I put the program in the workbook with PROC EXPORT.&lt;BR /&gt;
1) Save this program as&lt;BR /&gt;
&lt;B&gt;c:\temp\savepgm.sas&lt;/B&gt; &lt;BR /&gt;
(if you do not save it under this name, then step 3 won't work)&lt;BR /&gt;
2) Step 1 and Step 2 are just modifications of your original proc SQL steps using SASHELP files.&lt;BR /&gt;
3) Step 3 reads a .SAS program file into a SAS dataset and then uses PROC EXPORT to put the dataset into a worksheet.&lt;BR /&gt;
  &lt;BR /&gt;
[pre]&lt;BR /&gt;
** Step 1;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table endsql1 as&lt;BR /&gt;
select region, &lt;BR /&gt;
       product,&lt;BR /&gt;
       sum(actual) as ActTot,&lt;BR /&gt;
       sum(predict) as PredTot&lt;BR /&gt;
from sashelp.prdsale&lt;BR /&gt;
group by region, product;&lt;BR /&gt;
quit;&lt;BR /&gt;
    &lt;BR /&gt;
proc export data = endsql1&lt;BR /&gt;
dbms = excel2000&lt;BR /&gt;
outfile = "c:\temp\END.xls"&lt;BR /&gt;
replace;&lt;BR /&gt;
sheet = 'IssueDate';&lt;BR /&gt;
run;&lt;BR /&gt;
     &lt;BR /&gt;
** Step 2;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table endsql2 as&lt;BR /&gt;
select country, product,&lt;BR /&gt;
       sum(actual) as ActTot,&lt;BR /&gt;
       sum(predict) as PredTot&lt;BR /&gt;
from sashelp.prdsal2&lt;BR /&gt;
group by country, product;&lt;BR /&gt;
quit;&lt;BR /&gt;
     &lt;BR /&gt;
proc export data = endsql2&lt;BR /&gt;
dbms = excel2000&lt;BR /&gt;
outfile = "c:\temp\END.xls"&lt;BR /&gt;
replace;&lt;BR /&gt;
sheet = 'IssueAge';&lt;BR /&gt;
run;&lt;BR /&gt;
     &lt;BR /&gt;
** Step 3: Read the program into a SAS data set;&lt;BR /&gt;
filename wantpgm 'c:\temp\somepgm.sas';&lt;BR /&gt;
data readpgm;&lt;BR /&gt;
  length linenum 8 pgmline $250;&lt;BR /&gt;
  infile wantpgm length=lg;&lt;BR /&gt;
  input pgmline $varying. lg;&lt;BR /&gt;
  linenum + 1;&lt;BR /&gt;
run;&lt;BR /&gt;
     &lt;BR /&gt;
** write the program file -- with line numbers -- to a worksheet;&lt;BR /&gt;
proc export data = readpgm&lt;BR /&gt;
dbms = excel2000&lt;BR /&gt;
outfile = "c:\temp\END.xls"&lt;BR /&gt;
replace;&lt;BR /&gt;
sheet = 'SomePgm';&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
   &lt;BR /&gt;
The first DATA step program in Step 3 reads whatever file you have specified in the FILENAME statement -- this could be ANY file, but it happens to be a .SAS program file. &lt;BR /&gt;
&lt;BR /&gt;
There are only 2 variables in the SAS dataset -- linenum and pgmline. You don't really need linenum, but it's a good idea to have it in case you accidentally sort the program while it's in the worksheet -- you can get the original program back in order. Of course, if you have program lines longer than 250 characters, you'd have to change the LENGTH statement accordingly.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 18 Jan 2008 00:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6420#M253</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-01-18T00:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data totals and descriptive info in Excel output w/ proc export</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6421#M254</link>
      <description>Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
Thank you for the reply.  I'll try this and see how it goes.</description>
      <pubDate>Fri, 18 Jan 2008 14:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Getting-data-totals-and-descriptive-info-in-Excel-output-w-proc/m-p/6421#M254</guid>
      <dc:creator>Kenbutsu</dc:creator>
      <dc:date>2008-01-18T14:16:59Z</dc:date>
    </item>
  </channel>
</rss>

