<?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: Using Proc Tabulate in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13422#M1974</link>
    <description>How I can determine which observation is missing after I run Proc tabulate?  The original dataset has one more observation than the dataset that Proc tabulate outputs. Thanks,</description>
    <pubDate>Fri, 25 Apr 2008 23:00:27 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-25T23:00:27Z</dc:date>
    <item>
      <title>Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13417#M1969</link>
      <description>I inherited the following program but want to modify it so that I can have&lt;BR /&gt;
an output line listing per school with the following information on each line:&lt;BR /&gt;
&lt;BR /&gt;
coname  type distname schname  total #PBE   %PBE.&lt;BR /&gt;
&lt;BR /&gt;
How can I do that?&lt;BR /&gt;
&lt;BR /&gt;
title2 'TABLE 1: TOTAL ENROLLMENT AND STATUS';&lt;BR /&gt;
proc tabulate data=kasch_update noseps;&lt;BR /&gt;
  class coname type distname schname;&lt;BR /&gt;
  var total pbe;&lt;BR /&gt;
  format type $type.;&lt;BR /&gt;
  table coname='COUNTY:'*type='SCHOOL TYPE:'*distname='SCHOOL DISTRICT:',&lt;BR /&gt;
    schname='SCHOOL NAME', &lt;BR /&gt;
  total*f=comma9.&lt;BR /&gt;
  pbe*f=comma9.*(sum pctsum&lt;TOTAL&gt;*f=comma9.2)&lt;BR /&gt;
  / row=float rtspace=50;&lt;BR /&gt;
  label&lt;BR /&gt;
    total = 'TOTAL PEOPLE'&lt;BR /&gt;
    pbe = 'ENTRANTS WITH PBE';&lt;BR /&gt;
  keylabel sum = 'NUMBER' pctsum = 'PERCENT';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Teresa&lt;/TOTAL&gt;</description>
      <pubDate>Thu, 24 Apr 2008 21:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13417#M1969</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-24T21:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13418#M1970</link>
      <description>Hi, Teresa:&lt;BR /&gt;
  I'm not sure what you mean by an "output line listing" -- do you mean you do NOT want a PROC TABULATE table?&lt;BR /&gt;
&lt;BR /&gt;
Currently, it looks like you have a 3 dimensional table:&lt;BR /&gt;
[pre]&lt;BR /&gt;
table &lt;BR /&gt;
coname='COUNTY:'*type='SCHOOL TYPE:'*distname='SCHOOL DISTRICT:',  /* PAGE dimension */&lt;BR /&gt;
schname='SCHOOL NAME',   /* ROW dimension */&lt;BR /&gt;
total*f=comma9.  pbe*f=comma9.*(sum pctsum&lt;TOTAL&gt;*f=comma9.2)  /* COL dimension */&lt;BR /&gt;
/ row=float rtspace=50;&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Or do you mean that you want a different kind of report from Proc Tabulate, perhaps a report without the PAGE dimension. right now, it looks like you have a separate logical page for every unique combination of county, school type, and district. Then you should have school name going down the rows with total and the sum of PBE and PCTSUM of PBE going across the columns.&lt;BR /&gt;
&lt;BR /&gt;
Proc Tabulate uses table operators to arrange the structure of the table. So, every comma (,) means start a new dimension. If you have 2 commas in your table statement, then you would have 3 dimensions -- page, row and column. If you have 1 comma in your table statement, then you would have 2 dimensions, row and column. And if you have no commas in your table statement, then you would have only the column dimension in your table. The asterisk operator (*) tells Proc Tabulate to "nest" or "stack" columns...&lt;BR /&gt;
&lt;BR /&gt;
So, if you wanted to simply eliminate the PAGE dimension, you could change the comma after SCHOOL DISTRICT to an asterisk:&lt;BR /&gt;
[pre]&lt;BR /&gt;
table coname='COUNTY:'*type='SCHOOL TYPE:'*distname='SCHOOL DISTRICT:' * schname='SCHOOL NAME', &lt;BR /&gt;
total*f=comma9. pbe*f=comma9.*(sum pctsum&lt;TOTAL&gt;*f=comma9.2)&lt;BR /&gt;
/ row=float rtspace=50;&lt;BR /&gt;
    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
    &lt;BR /&gt;
However, that would leave school nested within district nested within type nested within county. If you mean you want a simple proc print listing, then you &lt;BR /&gt;
could just run a PROC PRINT with the appropriate VAR statement -- but PROC PRINT will not calculate summaries and/or percents for you.&lt;BR /&gt;
&lt;BR /&gt;
If you still want a summary report -- only "flattened", then you might try PROC REPORT with the GROUP usage for county, type, district and school name. However, since you are using a special denominator in TABULATE, you may need to get into issues of using COMPUTE blocks with PROC REPORT. For that, you might be better off contacting Tech Support for help.&lt;BR /&gt;
&lt;BR /&gt;
Yet another option is to have PROC TABULATE create an output data set for you by modifying the PROC TABULATE statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc tabulate data=kasch_update noseps out=work.tabout;&lt;BR /&gt;
  &lt;BR /&gt;
[/pre]&lt;BR /&gt;
   &lt;BR /&gt;
And in this case, a simple PROC PRINT on WORK.TABOUT may be what you want. You will probably have to rename some of the calculated variables in the WORK.TABOUT dataset because PROC TAB does not use your LABEL statement to name the variables.TABULATE also adds some automatic variables to the output dataset _TYPE_, _PAGE_ and _TABLE_ that are explained in the TABULATE documentation, but you can pretty much figure out what they mean by comparing your TABLE statement to the output dataset.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;/TOTAL&gt;&lt;/TOTAL&gt;</description>
      <pubDate>Thu, 24 Apr 2008 22:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13418#M1970</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-04-24T22:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13419#M1971</link>
      <description>Hi Cynthia:&lt;BR /&gt;
&lt;BR /&gt;
Thanks so very much! I appreciate your time.  You are a great help!&lt;BR /&gt;
&lt;BR /&gt;
teresa</description>
      <pubDate>Fri, 25 Apr 2008 18:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13419#M1971</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-25T18:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13420#M1972</link>
      <description>Hi, Teresa:&lt;BR /&gt;
  PROC TABULATE is very cool. I find that it does help to work backwards from a picture of the table I want to the table statement syntax.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 25 Apr 2008 18:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13420#M1972</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-04-25T18:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13421#M1973</link>
      <description>Hi Cynthia:&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much!!&lt;BR /&gt;
&lt;BR /&gt;
teresa</description>
      <pubDate>Fri, 25 Apr 2008 19:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13421#M1973</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-25T19:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13422#M1974</link>
      <description>How I can determine which observation is missing after I run Proc tabulate?  The original dataset has one more observation than the dataset that Proc tabulate outputs. Thanks,</description>
      <pubDate>Fri, 25 Apr 2008 23:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13422#M1974</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-25T23:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13423#M1975</link>
      <description>Hi:&lt;BR /&gt;
  Remember that PROC TABULATE is a SUMMARY procedure. It summarizes your data according to the class variables you give it. What if I have this file:&lt;BR /&gt;
[pre]&lt;BR /&gt;
grp subgrp amt&lt;BR /&gt;
aa    ww     1&lt;BR /&gt;
aa    ww     2&lt;BR /&gt;
bb    xx     3&lt;BR /&gt;
cc    yy     4&lt;BR /&gt;
dd    zz     5&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
It has 5 observations. The way PROC  TABULATE would work is that if I ran this PROC TABULATE program:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc tabulate data=sales out=work.tabout;&lt;BR /&gt;
title 'Proc Tabulate';&lt;BR /&gt;
class grp subgrp;&lt;BR /&gt;
var amt;&lt;BR /&gt;
table grp*subgrp,&lt;BR /&gt;
      amt*(n sum pctsum);&lt;BR /&gt;
run;&lt;BR /&gt;
       &lt;BR /&gt;
proc print data=work.tabout;&lt;BR /&gt;
title 'output dataset from proc tabulate has 4 observations';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Then PROC TABULATE would "collapse" or summarize the data based on the unique combinations of grp*subgrp that I had. The output from the PROC PRINT would be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
output dataset from proc tabulate has 4 observations              &lt;BR /&gt;
      &lt;BR /&gt;
                                                                             amt_&lt;BR /&gt;
                                                                           PctSum_&lt;BR /&gt;
Obs    grp    subgrp    _TYPE_    _PAGE_    _TABLE_    amt_N    amt_Sum      00&lt;BR /&gt;
       &lt;BR /&gt;
 1     aa       ww        11         1         1         2         3       20.0000&lt;BR /&gt;
 2     bb       xx        11         1         1         1         3       20.0000&lt;BR /&gt;
 3     cc       yy        11         1         1         1         4       26.6667&lt;BR /&gt;
 4     dd       zz        11         1         1         1         5       33.3333&lt;BR /&gt;
         &lt;BR /&gt;
[/pre]&lt;BR /&gt;
    &lt;BR /&gt;
This does not indicate that an observation is missing, just that, given my table statement and my combination of CLASS Variables, PROC TABULATE performed some summarizing. &lt;BR /&gt;
&lt;BR /&gt;
Look at the amt_N column ... 3 of the observations in the output dataset only had 1 observation contributing to the statistics, but GRP=AA and SUBGRP=WW statistics were derived from 2 observations.&lt;BR /&gt;
   &lt;BR /&gt;
Perhaps I misunderstood your original question. Since you had working PROC TABULATE code, I thought you wanted the summarizing that TABULATE does and just wanted an output table that was the equivalent of the TABULATE summary. &lt;BR /&gt;
&lt;BR /&gt;
If you do not want ANY summarization at all, then you should not use PROC TABULATE, you should use either PROC PRINT or PROC REPORT to create a "detail" or "listing" report.&lt;BR /&gt;
&lt;BR /&gt;
You could get this kind of report from PROC REPORT using the above 5 lines of data.&lt;BR /&gt;
 [pre]&lt;BR /&gt;
detail listing with pctsum       &lt;BR /&gt;
      &lt;BR /&gt;
                         Sum of    Percent&lt;BR /&gt;
  grp       subgrp          Amt        Sum&lt;BR /&gt;
  aa        ww                1     6.67%&lt;BR /&gt;
  aa        ww                2    13.33%&lt;BR /&gt;
  bb        xx                3    20.00%&lt;BR /&gt;
  cc        yy                4    26.67%&lt;BR /&gt;
  dd        zz                5    33.33%&lt;BR /&gt;
                      =========  =========&lt;BR /&gt;
                             15   100.00%&lt;BR /&gt;
                      =========  =========&lt;BR /&gt;
    &lt;BR /&gt;
[/pre] &lt;BR /&gt;
&lt;BR /&gt;
If you do not want PROC TABULATE to summarize your data, then you might wish to review what other procedures can do for your in regards to reports by reading the SAS documentation or contacting Tech Support for more help.&lt;BR /&gt;
&lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
Here's the program that I used to generate the above reports. In addition, there's an extra example using data called DIFFSALES -- which collapses down from 5 observations to 2 observations in the output dataset:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data sales;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input grp $ subgrp $ amt;&lt;BR /&gt;
datalines;&lt;BR /&gt;
aa ww 1&lt;BR /&gt;
aa ww 2&lt;BR /&gt;
bb xx 3&lt;BR /&gt;
cc yy 4&lt;BR /&gt;
dd zz 5&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
  &lt;BR /&gt;
ods listing;&lt;BR /&gt;
option nocenter;&lt;BR /&gt;
   &lt;BR /&gt;
proc print data=sales;&lt;BR /&gt;
title 'original data set has 5 observations';&lt;BR /&gt;
run;&lt;BR /&gt;
          &lt;BR /&gt;
proc report data=sales nowd;&lt;BR /&gt;
title 'detail listing with pctsum';&lt;BR /&gt;
  column grp subgrp amt amt=pamt;&lt;BR /&gt;
  define grp / display;&lt;BR /&gt;
  define subgrp / display;&lt;BR /&gt;
  define amt / sum 'Sum of Amt';&lt;BR /&gt;
  define pamt / pctsum 'Percent Sum' f=percent9.2;&lt;BR /&gt;
  rbreak after / summarize dol dul;&lt;BR /&gt;
run;&lt;BR /&gt;
        &lt;BR /&gt;
proc tabulate data=sales out=work.tabout;&lt;BR /&gt;
title 'Proc Tabulate';&lt;BR /&gt;
class grp subgrp;&lt;BR /&gt;
var amt;&lt;BR /&gt;
table grp*subgrp,&lt;BR /&gt;
      amt*(n sum pctsum);&lt;BR /&gt;
run;&lt;BR /&gt;
           &lt;BR /&gt;
proc print data=work.tabout;&lt;BR /&gt;
title 'output dataset from proc tabulate has 4 observations';&lt;BR /&gt;
run;&lt;BR /&gt;
                           &lt;BR /&gt;
data diffsales;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input grp $ subgrp $ amt;&lt;BR /&gt;
datalines;&lt;BR /&gt;
aa ww 1&lt;BR /&gt;
aa ww 2&lt;BR /&gt;
bb xx 3&lt;BR /&gt;
bb xx 4&lt;BR /&gt;
bb xx 5&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
            &lt;BR /&gt;
proc tabulate data=diffsales out=work.diffout;&lt;BR /&gt;
title 'Proc Tabulate Using DIFFSALES data';&lt;BR /&gt;
class grp subgrp;&lt;BR /&gt;
var amt;&lt;BR /&gt;
table grp*subgrp,&lt;BR /&gt;
      amt*(n sum pctsum);&lt;BR /&gt;
run;&lt;BR /&gt;
       &lt;BR /&gt;
proc print data=work.diffout;&lt;BR /&gt;
title 'DIFFOUT output dataset from proc tabulate has 2 observations';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 26 Apr 2008 01:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13423#M1975</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-04-26T01:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13424#M1976</link>
      <description>Hi Cynthia:&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much for your helpful explanations! I appreciate your time!!&lt;BR /&gt;
&lt;BR /&gt;
I see what you mean if there are two 'aa's in the dataset.  You helped me figure out the problem!  There was a duplicate observation in my dataset!&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much!!&lt;BR /&gt;
teresa</description>
      <pubDate>Tue, 29 Apr 2008 16:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-Proc-Tabulate/m-p/13424#M1976</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-29T16:18:14Z</dc:date>
    </item>
  </channel>
</rss>

