<?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: PROC TABULATE question - naming N &amp; PCTN variables in out= dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11118#M1212</link>
    <description>Cynthia,  &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your response.  I am already using the RENAME= option in the PROC TABULATE statement.  The problem is that the default column names in the output datset for certain statistic variables are NOT static/fixed.  PCTN is a good example of this.  SAS utilizes the following nomenclature for the PCTN column name in the output dataset:&lt;BR /&gt;
&lt;BR /&gt;
PctN_#&lt;BR /&gt;
&lt;BR /&gt;
where # represents the number of zeroes that correspond to the number of class variables.  Here are examples:&lt;BR /&gt;
&lt;BR /&gt;
3 class variables -&amp;gt; PctN_000&lt;BR /&gt;
5 class variables -&amp;gt; PctN_00000&lt;BR /&gt;
10 class variables -&amp;gt; PctN_0000000000&lt;BR /&gt;
15 class variables -&amp;gt; PctN_000000000000000&lt;BR /&gt;
N class variables -&amp;gt; PctN_[N zeroes]&lt;BR /&gt;
&lt;BR /&gt;
So every time I add or subtract a variable to the class statement, I also have to update the number of zeroes in PctN_# in the RENAME= statement.  This is very annoying/inconvenient, especially since the "N" statistic is NOT affected by this (the default column name is always "N" which does not require updating the RENAME= option every time).&lt;BR /&gt;
&lt;BR /&gt;
Is this expected naming behavior for the PCTN column in the output dataset?  What is the reason for adding zeroes at the end instead of simply using "PCTN" as the column name in the output dataset?</description>
    <pubDate>Wed, 28 Apr 2010 17:37:14 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-04-28T17:37:14Z</dc:date>
    <item>
      <title>PROC TABULATE question - naming N &amp; PCTN variables in out= dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11116#M1210</link>
      <description>Hello all,&lt;BR /&gt;
&lt;BR /&gt;
Code goes like this:&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=sasdata out=tabulateout;&lt;BR /&gt;
class var1 var2 var3 var4 var5;  &lt;BR /&gt;
table (var1 var2 var3 var4 var5)*(n=count pctn=count_pct);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The LST tabulate output shows the n and pctn variable as "COUNT" and "COUNT_PCT", respectively, as expected.  &lt;BR /&gt;
&lt;BR /&gt;
However, the output dataset (tabulateout) shows the corresponding variable names as just "N" and "PctN_00000" instead of "COUNT" and "COUNT_PCT".  &lt;BR /&gt;
&lt;BR /&gt;
Why this discrepancy?  Is there any way to force PROC TABULTE to name the output dataset variables as specified in the table statement?  The problem with the PctN_00000 variable name is that it is not static.  The "00000" actually corresponds to the number of class variables.  So if I added var6 and var7 to the class statement, the variable name would change to PctN_0000000.  This is very annoying and inconvenient.  Please advise.</description>
      <pubDate>Tue, 27 Apr 2010 22:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11116#M1210</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T22:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE question - naming N &amp; PCTN variables in out= dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11117#M1211</link>
      <description>Hi:&lt;BR /&gt;
  What you have in the TABLE statement only names the table columns in the "printed" output file or ODS output file -- it has no effect on what goes in the OUTPUT dataset (as a result of OUTPUT=). The usage of an '=' after a variable name in a TABLE statement only serves the purpose of providing a text string to act as a label for the column header in the "printed" or displayed output table. Normally, the string after the equal sign (=) is quoted, which serves to make the label function of the = more clear.&lt;BR /&gt;
 &lt;BR /&gt;
  However, you certainly can use the RENAME= dataset option to rename your output variables as shown in the program below.&lt;BR /&gt;
                     &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data sasdata;&lt;BR /&gt;
  set sashelp.prdsale;&lt;BR /&gt;
  var1 = region;&lt;BR /&gt;
  var2 = division;&lt;BR /&gt;
  var3 = country;&lt;BR /&gt;
  var4 = product;&lt;BR /&gt;
  var5 = prodtype;&lt;BR /&gt;
run;&lt;BR /&gt;
                &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc tabulate data=sasdata out=tabulateout;&lt;BR /&gt;
  title '1) Listing Output Table';&lt;BR /&gt;
  class var1 var2 var3 var4 var5; &lt;BR /&gt;
  table (var1 var2 var3 var4 var5)*(n='Count' pctn='Count_Pct');&lt;BR /&gt;
run;&lt;BR /&gt;
                             &lt;BR /&gt;
proc print data=tabulateout;&lt;BR /&gt;
  title 'Taking Defaults';&lt;BR /&gt;
run;&lt;BR /&gt;
                        &lt;BR /&gt;
&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc tabulate data=sasdata out=tabout(rename=(n=Count PctN_00000=Count_Pct));&lt;BR /&gt;
  title '2) Listing Output Table';&lt;BR /&gt;
  class var1 var2 var3 var4 var5; &lt;BR /&gt;
  table (var1 var2 var3 var4 var5)*(n='Count' pctn='Count_Pct');&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
proc print data=tabout;&lt;BR /&gt;
  title 'With RENAME';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 28 Apr 2010 01:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11117#M1211</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-28T01:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE question - naming N &amp; PCTN variables in out= dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11118#M1212</link>
      <description>Cynthia,  &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your response.  I am already using the RENAME= option in the PROC TABULATE statement.  The problem is that the default column names in the output datset for certain statistic variables are NOT static/fixed.  PCTN is a good example of this.  SAS utilizes the following nomenclature for the PCTN column name in the output dataset:&lt;BR /&gt;
&lt;BR /&gt;
PctN_#&lt;BR /&gt;
&lt;BR /&gt;
where # represents the number of zeroes that correspond to the number of class variables.  Here are examples:&lt;BR /&gt;
&lt;BR /&gt;
3 class variables -&amp;gt; PctN_000&lt;BR /&gt;
5 class variables -&amp;gt; PctN_00000&lt;BR /&gt;
10 class variables -&amp;gt; PctN_0000000000&lt;BR /&gt;
15 class variables -&amp;gt; PctN_000000000000000&lt;BR /&gt;
N class variables -&amp;gt; PctN_[N zeroes]&lt;BR /&gt;
&lt;BR /&gt;
So every time I add or subtract a variable to the class statement, I also have to update the number of zeroes in PctN_# in the RENAME= statement.  This is very annoying/inconvenient, especially since the "N" statistic is NOT affected by this (the default column name is always "N" which does not require updating the RENAME= option every time).&lt;BR /&gt;
&lt;BR /&gt;
Is this expected naming behavior for the PCTN column in the output dataset?  What is the reason for adding zeroes at the end instead of simply using "PCTN" as the column name in the output dataset?</description>
      <pubDate>Wed, 28 Apr 2010 17:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11118#M1212</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-28T17:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE question - naming N &amp; PCTN variables in out= dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11119#M1213</link>
      <description>Hi:&lt;BR /&gt;
  As explained in the documentation for OUT=&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473736.htm#a003065521" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473736.htm#a003065521&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;The number of observations in the output data set depends on the number of categories of data that are used in the tables and the number of subtables that are generated. &lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
And then this note &lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/14/884.html" target="_blank"&gt;http://support.sas.com/kb/14/884.html&lt;/A&gt; &lt;BR /&gt;
explains that:&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
In some cases TABULATE needs to generate multiple output data set&lt;BR /&gt;
variables for percentage statistics. That is because there can be&lt;BR /&gt;
multiple denominator crossings, just like there can be multiple&lt;BR /&gt;
numerator (table) crossings.&lt;BR /&gt;
                         &lt;BR /&gt;
This means that merely using the statistic name or analysis variable&lt;BR /&gt;
plus the statistic name will not guarantee a unique data set variable&lt;BR /&gt;
name.&lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
I believe the documentation explains why the statistic names for the output dataset cannot be static/fixed with PROC TABULATE.&lt;BR /&gt;
&lt;BR /&gt;
However, since you are only getting simple percents, without any complicated crossings, you might like the way that PROC FREQ creates the simple N and PCTN statistics in the output dataset. N is labelled FREQUENCY and PCTN is labelled PERCENT.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods output onewayfreqs=work.frqout;&lt;BR /&gt;
proc freq data=sasdata;&lt;BR /&gt;
  tables var1 var2 var3 var4 var5 / nocum ;&lt;BR /&gt;
run;&lt;BR /&gt;
                &lt;BR /&gt;
proc print data=frqout;&lt;BR /&gt;
  title 'Using PROC FREQ';&lt;BR /&gt;
run;&lt;BR /&gt;
            &lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 28 Apr 2010 19:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11119#M1213</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-28T19:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TABULATE question - naming N &amp; PCTN variables in out= dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11120#M1214</link>
      <description>Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
THANK YOU for providing the reference to the PROC FEQ ODS OUTPUT.  I had earlier used PROC FREQ but it didn't work for me due to the limitations of the TABLE option as it pertains to the output:&lt;BR /&gt;
&lt;BR /&gt;
From: &lt;A href="http://support.sas.com/documentation/cdl/en/procstat/63032/HTML/default/procstat_freq_sect009.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/procstat/63032/HTML/default/procstat_freq_sect009.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
"If you use multiple table requests in a TABLES statement, the contents of the OUTPUT data set correspond to the last table request. ."&lt;BR /&gt;
&lt;BR /&gt;
I was not aware that the ODS OUTPUT statement could bypass this limitation and would be able to capture the entire FREQ output regardless of the number of tables requests.  It's something new I have just learned today and I intend to explore the ODS features in more detail.  Thank you again!</description>
      <pubDate>Wed, 28 Apr 2010 20:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-TABULATE-question-naming-N-PCTN-variables-in-out-dataset/m-p/11120#M1214</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-28T20:43:00Z</dc:date>
    </item>
  </channel>
</rss>

