SyntaxHighlighter

Wednesday, June 8, 2016

Rules and Frame Style Attributes Visualized

Style attributes can be used to customize the appearance of SAS Output Delivery System (ODS) output. Styles can be assigned using proc template or style= options in procedures such as PROC REPORT displayed below.

Rules= control the internal borders while frame= control external borders. I have always found it difficult to visualize the combinations of rules= and frame= style attributes. As a result, I created the below code to display all of the combinations in a concise five page PDF file.

ods listing close ;
ods pdf file = "c:\temp\rulesandframes.pdf" startpage = no  ;
options nodate nonumber ;
ods escapechar = "~" noptitle ;

%macro rulesandframes ;
  %local 
    frames 
    frame 
    countframes 
    rules 
    rule 
    countrules 
    i 
    j ;

  %let frames = ABOVE BELOW BOX HSIDES LHS RHS VSIDES VOID ;
  %let countframes = %sysfunc( countw( &frames. ) ) ;
  %let rules = ALL COLS GROUPS NONE ROWS ;
  %let countrules  = %sysfunc( countw( &rules. ) ) ;

  %do i = 1 %to &countrules. ;
    %let rule = %scan( &rules., &i. ) ;
    title "RULES = &rule. ( internal borders )" ;

    %do j = 1 %to &countframes. ; 
      %let frame = %scan( &frames., &j. ) ;
      ods text = 
       "~{style[just=center]style(report) = [rules = &rule. frame = &frame.]}" ;
      proc report 
        nowd 
        data = sashelp.class( obs = 2 ) 
        style( report ) = [ rules = &rule. frame = &frame. ] ;
      run ;
    %end ;

    ods pdf startpage = now ;
  %end ;

%mend ;
%rulesandframes

ods pdf close ;
ods listing ;

No comments:

Post a Comment