BookmarkSubscribeRSS Feed
sri1
Obsidian | Level 7

Hi all,

 

I have the following code where the classification variable has 0 observations.Is there any way I can avoid warning "A class or frequency variable is missing on every observation" in log and still get the 0 count 

 

proc summary data=test nway completetypes;
class var1 var2/preloadfmt;
output out =ptest;
run;

 

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

 

Appreciate your reply.

 

Regards

Sri

2 REPLIES 2
Rick_SAS
SAS Super FREQ

The warning is there for a reason. It is a warning, not an error, so your program runs without errors.

 

There are a few things you can do to make the warning go away:

1. Perform a one-way analysis for var2 in this case. That is, change the CLASS statement to 
CLASS var2;

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 "get 0 count for type var1*var2." Instead, you will get a valid summation of the var2 variable. 

3. Use a WHERE clause to exclude the observations where var1 is missing. This will result in an empty output data set.  You could then use a data step to detect whether the output is empty, if necessary.

 

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 */

 

ballardw
Super User

@sri1 wrote:

Hi all,

 

I have the following code where the classification variable has 0 observations.Is there any way I can avoid warning "A class or frequency variable is missing on every observation" in log and still get the 0 count 

 

proc summary data=test nway completetypes;
class var1 var2/preloadfmt;
output out =ptest;
run;

 

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

 

Appreciate your reply.

 

Regards

Sri


Missing details, such as the Format definitions that are assigned to BOTH variables Var1 and Var2.

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.

Example:

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

So the definition of the formats may play a very significant role as well.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1835 views
  • 1 like
  • 3 in conversation