<?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: How do I display categories with no observation? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881910#M348466</link>
    <description>&lt;P&gt;Here is an example for PROC FREQ:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.heart end=last;
 w=1;output;
 if last then do;w=0;sex='NA';output;end;
run;

proc freq data=have;
table sex;
weight w/zero;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1687443140829.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85241i83CE5809045E65AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1687443140829.png" alt="Ksharp_0-1687443140829.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 14:12:15 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-06-22T14:12:15Z</dc:date>
    <item>
      <title>How do I display categories with no observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881899#M348460</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;which code do I have to use to ask SaS 9.4 to display all categories of a variable in a table even though some categories have no observation?&lt;/P&gt;&lt;P&gt;(f.e.: variable 'gender' with the categories "female", "male", "divers", "optout", "missing") and no person used the category "optout").&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did manage to generate a format (gender.) so all categories are defined, but I havent found a solution where or how use the defined format (gender.) in a proc to display responses to ALL categories; (especially for the proc freq, proc print, proc tabulate - so really basic steps).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;JDS1&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 13:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881899#M348460</guid>
      <dc:creator>JDS1</dc:creator>
      <dc:date>2023-06-22T13:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display categories with no observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881910#M348466</link>
      <description>&lt;P&gt;Here is an example for PROC FREQ:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.heart end=last;
 w=1;output;
 if last then do;w=0;sex='NA';output;end;
run;

proc freq data=have;
table sex;
weight w/zero;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1687443140829.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85241i83CE5809045E65AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1687443140829.png" alt="Ksharp_0-1687443140829.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 14:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881910#M348466</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-22T14:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display categories with no observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881912#M348468</link>
      <description>&lt;P&gt;Procs Means/Summary, Report and Tabulate have an option PRELOADFMT that will report on categories of class variables using the defined format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=yourdata;
   class gendervar / preloadfmt ;
   format gendervar gender. ;
   table gendervar, 
           n
           /printmiss;
run;&lt;/PRE&gt;
&lt;P&gt;Each procedure that uses Preloadfmt has slight differences on how it must be used and there are some interactions between them. Proc Tabulate for example requires one of table Printmiss option, or Order=data Class statement option or use of a CLASSDATA data set. Using multiple of these the order of the data display may change.&lt;/P&gt;
&lt;P&gt;Check each procedure for details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 14:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/881912#M348468</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-22T14:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display categories with no observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/882069#M348506</link>
      <description>Thank you so much! It worked</description>
      <pubDate>Fri, 23 Jun 2023 05:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/882069#M348506</guid>
      <dc:creator>JDS1</dc:creator>
      <dc:date>2023-06-23T05:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display categories with no observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/882070#M348507</link>
      <description>Thanks! I will try out the w/zero option as well!</description>
      <pubDate>Fri, 23 Jun 2023 05:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/882070#M348507</guid>
      <dc:creator>JDS1</dc:creator>
      <dc:date>2023-06-23T05:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display categories with no observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/882390#M348620</link>
      <description>&lt;P&gt;Hi, unfortunately this code (with w/zero in proc freq) didn't work out for my data.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 08:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-categories-with-no-observation/m-p/882390#M348620</guid>
      <dc:creator>JDS1</dc:creator>
      <dc:date>2023-06-26T08:08:08Z</dc:date>
    </item>
  </channel>
</rss>

