Search code examples
sasrtf

How to indent or center a PROC REPORT column output to RTF?


This is the output that I need in RTF format:

**DEMOGRAPHICS A-B**
Age             
   n          18    
   Mean       30.4
   SD         6.29
   Min        18    
   Median     30.5
   Max        39    

but I am getting this result:

**DEMOGRAPHICS A-B**
Age             
n         18    
Mean      30.4
SD        6.29
Min       18    
Median    30.5
Max       39

How do I left align age and center the remaining variables?

Here is my code:

proc report data = FINAL2  split = "@" 
 STYLE(REPORT)=[BACKGROUND=WHITE BORDERCOLOR=BLACK BORDERWIDTH=0.1 ASIS=on  FRAME=HSIDES RULES=GROUPS]
       STYLE(HEADER)=[BACKGROUND=WHITE];

    COLUMN DESC STAT1;

    define DESC / "Demographic Characteristics"  style(column)=[cellwidth=30%] style(header)=[just=left asis = on] ;
    define STAT1 /"A - B@(N=18)" style(column header)=[cellwidth = 20%] style(header)=[just = left asis = yes]; 

Solution

  • You can use a compute block to do this. This would be executed per row but you could conditionally apply a column-specific style from there based on the variable's value being 'Age' or something else.

    For example (you can add this after the define statements in your report step):

    compute desc;
      if desc ^= 'Age' then
        call define(_COL_, "style", "style=[paddingleft=3em]");
    endcomp;
    

    This would apply a 3em padding to each desc column that doesn't match 'Age'.