Stat-Tech Services, LLC

Example RTF Program


[STS Home Page] [Macro Reporting System] [RTF Main Page] [RTF Macros Documentation]


The following program generates some fake data and prints the listing to an RTF file (test002.rtf):

/*
* Program: TEST002.SAS
* Purpose: Demonstrate RTF System
* Author: DeMuth
* Date: 08 Feb 2000
*/

%include '\mrs\rtfinit.sas' ;
%include '\mrs\rtftitle.sas' ;
%include '\mrs\rtffoot.sas' ;
%include '\mrs\rtftail.sas' ;
%include '\mrs\rtfcol.sas' ;
%include '\mrs\rtf.sas' ;
%include '\mrs\rtfspan.sas' ;
%include '\mrs\rtfspend.sas' ;

/* This data step generates artificial data that will be passed to the
   RTF macros. The FORMAT procedure assigns verbal anchors to the
   generated data.  STS has a collection of macros for producing
   test data.  These macros can be requested by sending a message to
   stattech@nc.rr.com or jiwaniszek@nc.rr.com
*/
data test ;
    do i = 1 to 40 ;
        patno = 100 + i ;
        risk = rantbl(412342,0.7,0.3) ;
        trt = rantbl(34151,0.5,0.5) ;
        gender = rantbl(341,0.3,0.7) ;
        age = 30 + 3*rannor(23432) ;
        race = rantbl(4252,0.3,0.4,0.3) ;
        output;
        end ;
    run;

proc format ;
    value trt 1 = 'Active Drug'
              2 = 'Placebo' ;
    value risk 1 = 'Low'
               2 = 'High' ;
    value gender 1 = 'Female' 2 = 'Male' ;
    value race 1 = 'African American'
               2 = 'Asian'
               3 = 'Caucasian' ;
    run;

/* Initialize the macro system by identifying the output RTF file, input data set
   table style, and other parameters.  Font, font size, and margins are also controlled
   here.
*/
%rtfinit(filename=test002.rtf,
         data=test,
         title=Table 1,
         style=box,
         headskip=N,
         labbold=N,
         labital=Y,
         author=g DeMuth,
         company=STS,
         tablines=23,
         topmsg=%bquote((Listing continued from previous page.)),
         contmsg=%bquote((continued)),contjst=S) ;
 

    %* Table titles have independent font cotrols and provide three areas of justification (R, C, L) ;
    %rtftitle(text=%bquote(Stat-Tech Services, LLC),
          fontnum=3,fontsize=16,bold=Y) ;
    %rtftitle(text=%str( ),fontnum=3) ;
    %rtftitle(text=%bquote(Listing 1),fontnum=3) ;
    %rtftitle(text=%bquote(Demographic Characteristics),fontnum=3) ;
    %rtftitle(text=%str( ),fontnum=3) ;

    %* Footnotes Come in two styles (tail and regular). Font control and justification options are similar to titles.;
    %rtftail(text=%bquote(\super 1\nosupersub High risk indicates previous drug resistant disease.),fontnum=3) ;
    %rtffoot(text=%str( )) ;
    %rtffoot(ltext=%bquote(Generated by test001.sas) on &sysdate : &systime,fontnum=3,lmarg=60) ;

    %* Columns and spanning header ;
    %rtfspan(text=%bquote( )) ; %* Dummy spanning header ;
       %rtfcol(var=risk,
               fmt=risk.,
               just=l,
               label=%bquote(Risk Group \super 1\nosupersub),type=BY) ;
       %rtfcol(var=patno,fmt=3.,label=Patient) ;
    %rtfspend ;

    %rtfspan(text=Demographic Variables) ;
        %rtfcol(var=gender,fmt=gender.,label=Gender) ;
        %rtfcol(var=age,fmt=4.1,label=%bquote(Age*(yrs)),just=d) ;
        %rtfcol(var=race,fmt=race.,label=Ethnicity,width=15,just=l) ;
        %rtfspend ;

    %rtf ;

run ;
 

Output file:  test002.rtf