Proc Report-Assigning a different format for different rows

1.4k views Asked by At

I have a table that is current laid out in the way I want. The only issue is that when I went to assign the format, it carried over the format for all values. I have a row that should be total, but I'm unsure how to strip the formatting on this row only in proc report:

Output

Want: total line to show no decimals as they are count but the rest of the table to keep same format.

    %let gray=CXBFBFBF;
    %let blue=CX13478C;
    %let purple=CXDEDDED;
    title j=c h=10pt f='Calibri' color=black "Table 1-Distribution, CY2016-CY2018";
        options orientation = landscape nonumber nodate leftmargin=0.05in rightmargin=0.05in;
        ods noproctitle noresults escapechar='^';
        ods rtf  file = "path.rtf";
         proc report data= work.temp nowd spanrows  style(report)={width=100%}
            style(header)=[vjust=b font_face = Calibri fontsize=9pt font_weight=bold background=&blue. foreground=white borderrightcolor=black];
            /*List variables in order to select order of columns in table*/
        col ( m_type 
                  ('^S={borderbottomcolor=&blue. vjust=b borderbottomwidth=0.02 }'('^S={borderbottomcolor=&blue. vjust=b borderbottomwidth=0.01 cellheight=0.20in}Age in Years' d_char_desc)) 
                  ('^S={cellheight=0.20in}Missing Information' 
                  ('^S={borderbottomcolor=&blue. borderbottomwidth=0.02 cellheight=0.18in}' percentage16_1)
                  ('^S={borderbottomcolor=&blue. borderbottomwidth=0.02 cellheight=0.18in}' percentage17_1)
                  ('^S={borderbottomcolor=&blue. borderbottomwidth=0.02 cellheight=0.18in}' percentage18_1))
);
define m_type /order=data group noprint style = [vjust=b just=left cellwidth=0.60in font_face='Times New Roman' fontsize=9pt];

        define d_char_desc / order=data display  style = [vjust=b just=left cellwidth=0.60in font_face='Times New Roman' fontsize=9pt]
                         '' style(header)=[vjust=b just=left cellheight=0.18in] style(column)=[vjust=b just=left cellheight=0.35in cellwidth=0.60in];
        define percentage16_1  /display style = [vjust=b just=center  cellwidth=0.60in cellheight=0.05in font_face='Times New Roman' fontsize=9pt] 
                         'CY2016' style(header)=[vjust=b just=center cellheight=0.18in] style(column)=[vjust=b just=center cellheight=0.20in cellwidth=0.40in];
        define percentage17_1 /display style = [vjust=b just=center  cellwidth=0.45in cellheight=0.05in font_face='Times New Roman' fontsize=9pt] 
                         'CY2017' style(header)=[vjust=b just=center cellheight=0.18in] style(column)=[vjust=b just=center cellheight=0.20in cellwidth=0.40in];
        define percentage18_1  /display style = [vjust=b just=center  cellwidth=0.45in cellheight=0.05in font_face='Times New Roman' fontsize=9pt] 
                         'CY2018' style(header)=[vjust=b just=center cellheight=0.18in] style(column)=[vjust=b just=center cellheight=0.20in cellwidth=0.40in];
compute m_type;    
if m_type = 'm_tot' then
call define (_row_, 'style', 'style=[fontweight=bold background=&gray. font_face=Times]');
endcomp;
run;
ods rtf close;
1

There are 1 answers

0
Richard On

You will have to explicitly format the numeric values in respective compute blocks. The numeric value referenced will depend on the analysis statistic and the syntax will be variable.statistic.

Your data (not shown) appears to be some form of pre-computed aggregation, based on the m_type = 'm_tot' source code. In that case the reference would be something like percentage16_1.sum (sum is the default analysis for numeric variables when there is a grouping specified)

Example:

Summarize some SASHELP.CARS variables and change the format for the Ford make.

proc report data=sashelp.cars;
  column ( 
    make

    horsepower mpg_city mpg_highway 

    horsepower_custom
    mpg_city_custom
    mpg_highway_custom
  );

  define make / group ;*noprint;

  define horsepower  / analysis noprint mean ;  
  define mpg_city    / analysis noprint mean ;  
  define mpg_highway / analysis noprint mean ;  

  define horsepower_custom / computed style=[textalign=right];
  define mpg_city_custom / computed style=[textalign=right];
  define mpg_highway_custom / computed style=[textalign=right];

  compute horsepower_custom / character length=10;
    if make = 'Ford' 
      then horsepower_custom = put (horsepower.mean, 10.4);
      else horsepower_custom = put (horsepower.mean, 8.1);
  endcomp;

  compute mpg_city_custom / character length=10;
    if make = 'Ford' 
      then mpg_city_custom = put (mpg_city.mean, 10.5);
      else mpg_city_custom = put (mpg_city.mean,  8.2);
  endcomp;

  compute mpg_highway_custom / character length=10;
    if make = 'Ford' 
      then mpg_highway_custom = put (mpg_highway.mean, 10.6);
      else mpg_highway_custom = put (mpg_highway.mean,  8.3);
  endcomp;
run;

enter image description here