tags:

views:

158

answers:

2

I have a SAS program that loops through certain sets of data and generates a bunch of reports to an ODS HTML destination.

Sometimes, due to small sets of data I run these reports for, a certain PROC REPORT will not generate because, for this set of data I'm on, there is no data to report. I get this message for those instances:

WARNING: A GROUP, ORDER, or ACROSS variable is missing on every observation.

What I want in the HTML is to display some sort of message for these like "did not generate" or something.

I tried to use return/error codes or the warning text above to detect this, but the error code is 0 (no problem, really?) and the warning text doesn't reset if the next PROC REPORT generates OK.

If it is of any importance, I'm using a data step with CALL EXECUTE to get all this PROC REPORT code generated for these sets of data.

Is there any way to generate this "did not generate" message or at least to catch these warnings per PROC REPORT?

+1  A: 

You can substitute in a value for the missing observations in your report.

First redefine missing values to some character. I think you can only use a single character, I could be wrong, though.

options missing='M';run;

Then make sure to use the "missing" option in your PROC REPORT.

proc report data=somedata nowd headline missing;
....
run;

EDITS BASED ON COMMENTS

To get comments to show up, I see a few possibilities.

One, scan the the data set and check for missing values. If any are present throw a message out.

Data _Null_;
  Set dataset;
  file print notitles;
  if obs = . then do;
    put @01 'DID NOT COMPUTE';
    stop;
  end;
run;

Two, add a column with a compute:

define xx /computed "(Message)";    
compute xx /char length=16 ;
if obs =. then xx = 'did not compute value in row';

Three, a conditional line using compute:

compute after obs;
  if obs = . then do;
     line @1 "DID NOT COMPUTE";
  end;
endcomp;

endcomp;

Mark
Thanks Mark - this would get at least the PROC REPORT table to show up, but I was hoping for a message of some type to display.
chucknelson
@chucknelson: sorry, I misunderstood, you want your "did not generate" to show up within the HTML below/above the table?
Mark
Cool - yeah, I think I was looking for some magical PROC REPORT option, but I don't think one exists! ;) The DATA step where I just check to see if there is valid data for the report will work just fine for my purposes - thanks Mark!
chucknelson
A: 

See: http://www2.sas.com/proceedings/sugi26/p095-26.pdf

Look for the MTANYOBS macro and the section on printing a 'no observations' page.

LoriG