<?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 proc tabulate show zero categories in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636776#M189227</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using proc tabulate and I want to see also categories with zero count(or zero sum..)&lt;/P&gt;
&lt;P&gt;In data set SAShelp.class there are 2 categories for varaible Sex : M&amp;nbsp; and F.&lt;/P&gt;
&lt;P&gt;I want to show also another category called :Trans&lt;/P&gt;
&lt;P&gt;I am using classdata option but I get an error. ("class varaible sex was not found in the preload data set)&lt;/P&gt;
&lt;P&gt;I found that If I give another name "T"&amp;nbsp; instead of "Trans"&amp;nbsp; then it works well.&lt;/P&gt;
&lt;P&gt;MAy anyone solve the issue please and explain why if length longer than 1 then I get error?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data levels;
input sex $5.;
cards;
F
M
Trans
;
Run;

proc tabulate data=sashelp.class  classdata=levels;
class sex;
table sex,n pctn;
Run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Apr 2020 06:37:36 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-04-02T06:37:36Z</dc:date>
    <item>
      <title>proc tabulate show zero categories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636776#M189227</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using proc tabulate and I want to see also categories with zero count(or zero sum..)&lt;/P&gt;
&lt;P&gt;In data set SAShelp.class there are 2 categories for varaible Sex : M&amp;nbsp; and F.&lt;/P&gt;
&lt;P&gt;I want to show also another category called :Trans&lt;/P&gt;
&lt;P&gt;I am using classdata option but I get an error. ("class varaible sex was not found in the preload data set)&lt;/P&gt;
&lt;P&gt;I found that If I give another name "T"&amp;nbsp; instead of "Trans"&amp;nbsp; then it works well.&lt;/P&gt;
&lt;P&gt;MAy anyone solve the issue please and explain why if length longer than 1 then I get error?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data levels;
input sex $5.;
cards;
F
M
Trans
;
Run;

proc tabulate data=sashelp.class  classdata=levels;
class sex;
table sex,n pctn;
Run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 06:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636776#M189227</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-04-02T06:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show zero categories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636780#M189230</link>
      <description>&lt;P&gt;From the docu &lt;A href="https://go.documentation.sas.com/?docsetId=proc&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=n1hpbwr9acrbmen1e2d6hxjkotm1.htm&amp;amp;locale=en#n1k7cffoxmhkexn1k3e4wc7yu6s9" target="_self"&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xisDoc-restriction"&gt;Restriction&lt;/TD&gt;
&lt;TD class="xisDoc-summaryText"&gt;The CLASSDATA= data set must contain all class variables. Their data type and format must match the corresponding class variables in the input data set.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sex from sashelp.class has a length of $1 so a string of Trans is not possible. Given that you want Proc Tabulate to print possible values it also wouldn't make sense to allow a longer string for the classdata table.&lt;/P&gt;
&lt;P&gt;You could populate T into your classdata table and then create a format used in Proc Tabulate which prints T as Trans.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 07:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636780#M189230</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-04-02T07:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show zero categories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636781#M189231</link>
      <description>&lt;P&gt;The variables must be defined identically in the source and classdata datasets. SEX in sashelp.class has a length of 1, so you must define it with that length in the classdata dataset.&lt;/P&gt;
&lt;P&gt;Therefore, this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $sex
  "F"="Female"
  "M"="Male"
  "T"="Trans"
;
run;

Data levels;
input sex $1.;
cards;
F
M
T
;

proc tabulate data=sashelp.class  classdata=levels;
format sex $sex.;
class sex;
table sex,n pctn;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 07:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-zero-categories/m-p/636781#M189231</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-02T07:01:51Z</dc:date>
    </item>
  </channel>
</rss>

