<?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 to avoid warning &amp;quot;A class or frequency variable is missing on every observation&amp;quot; in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849836#M82374</link>
    <description>&lt;P&gt;The warning is there for a reason. It is a warning, not an error, so your program runs without errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few things you can do to make the warning go away:&lt;/P&gt;
&lt;P&gt;1. Perform a one-way analysis for var2 in this case. That is, change the CLASS statement to&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;CLASS var2;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;2. Use the MISSING option on the CLASS statements to tell the procedure that missing values are a valid category for summation. If you do that, you won't "&lt;SPAN&gt;get 0 count for type var1*var2." Instead, you will get a valid summation of the var2 variable.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Use a WHERE clause to exclude the observations where var1 is missing. This will result in an empty output data set.&amp;nbsp; You could then use a data step to detect whether the output is empty, if necessary.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
var1 = .;
do i = 1 to 10;
   var2 = 0;
   output;
end;
do i = 1 to 5;
   var2 = 1;
   output;
end;
run;


/* 1. one-way anaysis of var2 */
proc summary data=test nway completetypes;
class var2;
output out =ptest;
run;

proc print; run;

/* 2. let MISSING be a valid category */
proc summary data=test nway completetypes;
class var1 var2 / missing;
output out =ptest;
run;

proc print; run; 

/* 3. exclude obs for var1=MISSING */
proc summary data=test nway completetypes;
where var1 is not missing;
class var1 var2;
output out =ptest;
run;

proc print; run;   /* NO OBS */

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Dec 2022 11:28:07 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-12-15T11:28:07Z</dc:date>
    <item>
      <title>How to avoid warning "A class or frequency variable is missing on every observation"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849834#M82373</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code where the classification variable has 0 observations.Is there any way I can avoid&amp;nbsp;warning "A class or frequency variable is missing on every observation" in log and still get the 0 count&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=test nway completetypes;&lt;BR /&gt;class var1 var2/preloadfmt;&lt;BR /&gt;output out =ptest;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Values of var1 are all missing , is there any way I can get 0 count for type var1*var2 and avoid the above message in log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate your reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Sri&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 11:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849834#M82373</guid>
      <dc:creator>sri1</dc:creator>
      <dc:date>2022-12-15T11:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid warning "A class or frequency variable is missing on every observation"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849836#M82374</link>
      <description>&lt;P&gt;The warning is there for a reason. It is a warning, not an error, so your program runs without errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few things you can do to make the warning go away:&lt;/P&gt;
&lt;P&gt;1. Perform a one-way analysis for var2 in this case. That is, change the CLASS statement to&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;CLASS var2;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;2. Use the MISSING option on the CLASS statements to tell the procedure that missing values are a valid category for summation. If you do that, you won't "&lt;SPAN&gt;get 0 count for type var1*var2." Instead, you will get a valid summation of the var2 variable.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Use a WHERE clause to exclude the observations where var1 is missing. This will result in an empty output data set.&amp;nbsp; You could then use a data step to detect whether the output is empty, if necessary.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
var1 = .;
do i = 1 to 10;
   var2 = 0;
   output;
end;
do i = 1 to 5;
   var2 = 1;
   output;
end;
run;


/* 1. one-way anaysis of var2 */
proc summary data=test nway completetypes;
class var2;
output out =ptest;
run;

proc print; run;

/* 2. let MISSING be a valid category */
proc summary data=test nway completetypes;
class var1 var2 / missing;
output out =ptest;
run;

proc print; run; 

/* 3. exclude obs for var1=MISSING */
proc summary data=test nway completetypes;
where var1 is not missing;
class var1 var2;
output out =ptest;
run;

proc print; run;   /* NO OBS */

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 11:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849836#M82374</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-15T11:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid warning "A class or frequency variable is missing on every observation"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849901#M82375</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80196"&gt;@sri1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code where the classification variable has 0 observations.Is there any way I can avoid&amp;nbsp;warning "A class or frequency variable is missing on every observation" in log and still get the 0 count&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=test nway completetypes;&lt;BR /&gt;class var1 var2/preloadfmt;&lt;BR /&gt;output out =ptest;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Values of var1 are all missing , is there any way I can get 0 count for type var1*var2 and avoid the above message in log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate your reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Sri&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Missing details, such as the Format definitions that are assigned to BOTH variables Var1 and Var2.&lt;/P&gt;
&lt;P&gt;You should show the entire code and all messages from the log. It is possible that you have additional information that formats are not acceptable for the Preloadfmt option.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;40   proc summary data=sashelp.class completetypes;
41      class sex age/preloadfmt ;
42      format age f2.;
43      var height ;
44      output out=want max=;
45   run;

WARNING: The format for variable Age cannot be preloaded. A finite set of formatted values cannot
         be produced from the format.  The format is not recognized, is a SAS format, calls a
         function, or contains a nested format in its definition. Preload will have no effect.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.WANT has 21 observations and 5 variables.
NOTE: PROCEDURE SUMMARY used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;So the definition of the formats may play a very significant role as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 16:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-avoid-warning-quot-A-class-or-frequency-variable-is/m-p/849901#M82375</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-15T16:13:00Z</dc:date>
    </item>
  </channel>
</rss>

