<?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 categories with zero:use 2 varaibles with categories zero in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636886#M189275</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using sashelp.class raw data in order to create a summary report.&lt;/P&gt;
&lt;P&gt;I want to add categories in age varaible that are not in the raw data (will get values 0)&lt;/P&gt;
&lt;P&gt;I also want o to add category of Sex variable that is not in the raw table (will get values 0)&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use classdata option in proc tabulate in order to show categories with value 0.&lt;/P&gt;
&lt;P&gt;The problem is that it is not working.&lt;/P&gt;
&lt;P&gt;Any idea why?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data level1;
input sex $1.;
cards;
F
M
T
;
Run;

proc format;
value $sex
"F"="Female"
"M"="Male"
"T"="Trans"
;
Run;

Data level2;
input age;
cards;
10
11
12
13
14
15
16
17
18
;
Run;

proc tabulate data=ashelp.class   classdata=level1   classdata=level2;
class sex age;
var height;
table sex=''  all='ALL',
 (age*N*f=8.  all='ALL'    age *height=''*mean*f=8.1  all='ALL');
Run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Apr 2020 14:57:30 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-04-02T14:57:30Z</dc:date>
    <item>
      <title>proc tabulate show categories with zero:use 2 varaibles with categories zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636886#M189275</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using sashelp.class raw data in order to create a summary report.&lt;/P&gt;
&lt;P&gt;I want to add categories in age varaible that are not in the raw data (will get values 0)&lt;/P&gt;
&lt;P&gt;I also want o to add category of Sex variable that is not in the raw table (will get values 0)&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use classdata option in proc tabulate in order to show categories with value 0.&lt;/P&gt;
&lt;P&gt;The problem is that it is not working.&lt;/P&gt;
&lt;P&gt;Any idea why?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data level1;
input sex $1.;
cards;
F
M
T
;
Run;

proc format;
value $sex
"F"="Female"
"M"="Male"
"T"="Trans"
;
Run;

Data level2;
input age;
cards;
10
11
12
13
14
15
16
17
18
;
Run;

proc tabulate data=ashelp.class   classdata=level1   classdata=level2;
class sex age;
var height;
table sex=''  all='ALL',
 (age*N*f=8.  all='ALL'    age *height=''*mean*f=8.1  all='ALL');
Run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 14:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636886#M189275</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-04-02T14:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show categories with zero:use 2 varaibles with categories zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636888#M189276</link>
      <description>&lt;P&gt;Use PRELOADFMT option.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1f1t9bipbeqy5n1vowhzzk3vuby.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1f1t9bipbeqy5n1vowhzzk3vuby.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 15:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636888#M189276</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-02T15:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show categories with zero:use 2 varaibles with categories zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636890#M189278</link>
      <description>&lt;P&gt;Just to understand. Is Classdata option working only in a case that there is one variable???&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 15:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636890#M189278</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-04-02T15:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show categories with zero:use 2 varaibles with categories zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636900#M189284</link>
      <description>&lt;P&gt;CLASSDATA option needs to be specified once and should be a dataset that has the set of combinations you want to force to appear.&amp;nbsp; So something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table classdata as
select *
from level1,level2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 15:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636900#M189284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-02T15:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show categories with zero:use 2 varaibles with categories zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636906#M189287</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You should have received a WARNING with the 2 CLASSDATA options and then another error in your code, as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tab_error.png" style="width: 574px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37675i7999ADA4C8CB99AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="tab_error.png" alt="tab_error.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; However, you can generate the data for the CLASSDATA file a different way, as shown in the program below, which produces this result:&lt;/P&gt;
&lt;P&gt;Result showing TAB code fixed using new CLASSDATA:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tab_good_results.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37677iAC27FBBF812CA3E4/image-size/large?v=v2&amp;amp;px=999" role="button" title="tab_good_results.png" alt="tab_good_results.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code to make classdata:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data myclass;
length sex $1 age 8;
do sex = 'F', 'M', 'T';
  do age = 10 to 18 by 1;
     output;
  end;
end;
Run;

proc format;
value $sex
"F"="Female"
"M"="Male"
"T"="Trans"
;
Run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 15:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636906#M189287</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-04-02T15:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate show categories with zero:use 2 varaibles with categories zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636912#M189290</link>
      <description>&lt;P&gt;May you please show the full solution with classdata option ? (I understand that you created a table that has all required combinations of var sex and var age but it is still not working )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 15:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-show-categories-with-zero-use-2-varaibles-with/m-p/636912#M189290</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-04-02T15:51:37Z</dc:date>
    </item>
  </channel>
</rss>

