<?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: Summarize and calculate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354987#M83121</link>
    <description>&lt;P&gt;There are some obnoxious interactions that happen with formats on the INPUT statement and text with embedded blanks. Also pasting code into the main message window of the forum can cause some other issues with removing blanks and shifting columns. So it is hard to tell what your issue with infile may have been. Pasting code into a code box opened with the forum {i} menu icon is best to help with some of those issues.&lt;/P&gt;
&lt;P&gt;the example below will read the enr as well as the building name for the given data.&lt;/P&gt;
&lt;P&gt;You don't say whether you want a report or data set for a result.&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines missover;
   informat buildingname $10. buildingtype $8. responded $1. jurisdictn $9. enr best5. ;
   input buildingname 1-10  buildingtype  responded  jurisdictn  enr  ;
cards;
happy days private Y nottingha 100
learning   public  N nottingha
buildingbl private Y nottingha 55
montessori private N nottingha
bean stalk private Y brunswick 55
learning   private Y brunswick 22
early lear private Y brunswick 66
childtime  private N brunswick
risingstar public  N brunswick
doodlebugs public  Y brunswick 34
;

run;

proc means data=have mean;
  class jurisdictn buildingtype;
  var enr;
run;

proc tabulate data=have;
  class jurisdictn buildingtype;
  var enr;
  table  jurisdictn,
         buildingtype * enr*mean;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options in the proc tabulate let you adjust appearance to remove/change column labels but this should get you started.&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2017 17:23:41 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-05-01T17:23:41Z</dc:date>
    <item>
      <title>Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354982#M83118</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following data:&lt;/P&gt;
&lt;PRE&gt;data have;
infile datalines missover;
input buildingname $10. buildingtype $8. responded $1. jurisdictn $9. enr 3 ;
cards;
happy days privateY nottingha 100
learning public N nottingha
buildingbl privateY nottingha 55
montessori privateN nottingha
bean stalk privateY brunswick 55
learning private Y brunswick 22
early lear privateY brunswick 66
childtime private N brunswick
risingstar public N brunswick
doodlebugs public Y brunswick 34
;

run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I couldn't fingure out how to get the enrollment to show in the datatable using the infile statement&lt;/P&gt;
&lt;P&gt;Here are the calculations I need to do -- summarize by jursidiction and buldingtype:&amp;nbsp;sum of enrollment&amp;nbsp;divided by total&amp;nbsp;# that responded 'Y'&lt;BR /&gt;Calculations:&lt;/P&gt;
&lt;P&gt;jurisdiction&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;BR /&gt;nottingham&amp;nbsp;&amp;nbsp;&amp;nbsp; (100+55)/2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;brunswick&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (55+22+255)/3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;34/1&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Final results:&lt;BR /&gt;jursidiction&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;BR /&gt;nottingham&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 77.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;brunswick&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 110.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;34.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I do that?&amp;nbsp; Thanks!&amp;nbsp; I'm on Base SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 17:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354982#M83118</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-05-01T17:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354987#M83121</link>
      <description>&lt;P&gt;There are some obnoxious interactions that happen with formats on the INPUT statement and text with embedded blanks. Also pasting code into the main message window of the forum can cause some other issues with removing blanks and shifting columns. So it is hard to tell what your issue with infile may have been. Pasting code into a code box opened with the forum {i} menu icon is best to help with some of those issues.&lt;/P&gt;
&lt;P&gt;the example below will read the enr as well as the building name for the given data.&lt;/P&gt;
&lt;P&gt;You don't say whether you want a report or data set for a result.&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines missover;
   informat buildingname $10. buildingtype $8. responded $1. jurisdictn $9. enr best5. ;
   input buildingname 1-10  buildingtype  responded  jurisdictn  enr  ;
cards;
happy days private Y nottingha 100
learning   public  N nottingha
buildingbl private Y nottingha 55
montessori private N nottingha
bean stalk private Y brunswick 55
learning   private Y brunswick 22
early lear private Y brunswick 66
childtime  private N brunswick
risingstar public  N brunswick
doodlebugs public  Y brunswick 34
;

run;

proc means data=have mean;
  class jurisdictn buildingtype;
  var enr;
run;

proc tabulate data=have;
  class jurisdictn buildingtype;
  var enr;
  table  jurisdictn,
         buildingtype * enr*mean;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options in the proc tabulate let you adjust appearance to remove/change column labels but this should get you started.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 17:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354987#M83121</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-01T17:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354989#M83122</link>
      <description>&lt;P&gt;this should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; jurisdictn , &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;max(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; buildingtype=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'private'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sum_enr &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; private format =&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma10.1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;max(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; buildingtype= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'public'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sum_enr &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; public format = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma10.1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; jurisdictn, buildingtype, avg(enr) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sum_enr &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)t&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 17:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/354989#M83122</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-01T17:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355005#M83130</link>
      <description>&lt;P&gt;You have two topics with identical titles and content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please remove one of them.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 18:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355005#M83130</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-01T18:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355041#M83142</link>
      <description>Appreciate your help. How do I export to Excel?  Thanks.&lt;BR /&gt;</description>
      <pubDate>Mon, 01 May 2017 19:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355041#M83142</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-05-01T19:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355043#M83143</link>
      <description>Thanks. What does this do and mean:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;group by 1, 2)t&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 01 May 2017 19:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355043#M83143</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-05-01T19:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355061#M83145</link>
      <description>Thanks. I attempted to post a message and got an error message saying the was unable to process. So I copied what I had entered, closed the window, and opened a new window, pasted into the new window and posted.  I would delete but have responses for both.&lt;BR /&gt;</description>
      <pubDate>Mon, 01 May 2017 20:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355061#M83145</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-05-01T20:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize and calculate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355372#M83225</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40498"&gt;@jcis7&lt;/a&gt; wrote:&lt;BR /&gt;Appreciate your help. How do I export to Excel? Thanks.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Responses may depend on exactly what you mean by "export to Excel".&lt;/P&gt;
&lt;P&gt;If you want to end up with a semi-nice looking table then either ODS tagsets.excelxp or ODS Excel would work. Details differ but basically:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ODS Excel file="path/output.xlsx";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;Procedure code that generates output, may be &lt;STRONG&gt;many&lt;/STRONG&gt; outputs&amp;gt;&lt;/P&gt;
&lt;P&gt;ODS Excel close;&lt;/P&gt;
&lt;P&gt;would send the output to the named file.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 19:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-and-calculate/m-p/355372#M83225</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-02T19:28:27Z</dc:date>
    </item>
  </channel>
</rss>

