The SAS Output Delivery System and reporting techniques

Proc Freq Frequency Missing and ODS formatting

Reply
Super User
Posts: 11,343

Proc Freq Frequency Missing and ODS formatting

Goal: Control the text and appearance of the Frequency Missing= message and format of the numeric value displayed at the end of a PROC FREQ one-way table when there are missing values.

For example display "Not Tested = 3,422" in red italics.

I am using SAS 9.2.3 and have looked through a lot of ODS references. I thought this would require modification to the BASE.FREQ.ONEWAYLIST template but the definition doesn't have anything I can see that would control that part.

SAS Super FREQ
Posts: 8,868

Re: Proc Freq Frequency Missing and ODS formatting

Hi:

  I don't think the "missing" note is controlled within the TABLE template. I think it is text that the procedure writes directly to the output report, as a line of text. I believe that the PROCTITLE style element is used to control the appearance of that piece of the report.

  For example, I can alter the appearance of the missing note in the code below. If you didn't want the actual procedure title (The Freq Procedure) to be on the report, you can disappear it by issuing the ODS NOPTITLE; statement.

cynthia

** make some data with missing values for age;
data makemiss;
  set sashelp.class;
  if age gt 14 then age = .;
run;

  

** establish the path for templates;
ods path work.tmp(update)
         sasuser.templat(update)
         sashelp.tmplmst(read);
 
** create a style template;
proc template;
  define style styles.notefreq;
  parent=styles.sasweb;
  class proctitle /
     fontsize=12pt
     color=red
     fontstyle=italic
     fontweight=bold;
  end;
run;
         
** use new style template;
ods html file='c:\temp\freqmiss.html' style=styles.notefreq;
   
ods ptitle;
proc freq data=makemiss;
  title '1) Procedure Title and missing note both red';
  tables age;
run;
 
ods noptitle;
proc freq data=makemiss;
  title '2) No Procedure Title and only missing note in red';
  tables age;
run;
   
ods _all_ close;

Super User
Posts: 11,343

Re: Proc Freq Frequency Missing and ODS formatting

Posted in reply to Cynthia_sas

Thank you for this information.

I was really hoping to find something that ODS addresses that would let me change the text displayed as well as how to access the object that contains the number of missing. The advantage of creating a bunch of one-way tables with a single pass of the data isn't going to be there apparently. The MISSPRINT table option doesn't quite work as I wanted to display the missing values somewhat separated. I was hoping to find something like the FMISSING available in the Base.Freq.CrossTabFreqs. Maybe I can find a way to make a crosstab look like a one-way table.

SAS Super FREQ
Posts: 8,868

Re: Proc Freq Frequency Missing and ODS formatting

Hi:

  Got it. Different question than what I thought you were looking for. There is a TABLE template answer -- but only for the TABLE itself, not the note at the bottom of the table.

  If you use MISSPRINT, the missing are included in the report table. To alter this row of information, you can use the CELLSTYLE...AS statement to test wehther FVARIABLE or VARIABLE are missing and if so, change the style of the whole row of the table. To keep things simple, I'm just using the EGDEFAULT style, so you can see the impact of using CELLSTYLE...AS.

cynthia

** use changed table template;

** make some data with missing values for age;

data makemiss;

  set sashelp.class;

  if age gt 14 then age = .;

run;

  

** establish the path for templates;

ods path work.tmp(update)

         sasuser.templat(update)

         sashelp.tmplmst(read);

    

proc template;

   edit Base.Freq.OneWayFreqs;

   notes "One-Way Frequency table";

   parent = Base.Freq.OneWayList;

   

   cellstyle FVariable is missing or Variable is missing

             as {vjust=m background=pink foreground=black

                 fontweight=bold height=.75in};

     

   end;

run;

  

ods listing close;

ods html file='c:\temp\missprint.html' style=egdefault;

        

ods noptitle;

proc freq data=makemiss;

  title '1) Use MISSPRINT and change TABLE Template';

  tables age / missprint;

run;

  

ods _all_ close;

Ask a Question
Discussion stats
  • 3 replies
  • 382 views
  • 3 likes
  • 2 in conversation