【问题标题】:Proc Report-Assigning a different format for different rowsProc Report-为不同的行分配不同的格式
【发布时间】:2019-11-07 20:16:50
【问题描述】:

我有一张当前按我想要的方式布置的表格。唯一的问题是,当我去分配格式时,它继承了所有值的格式。我有一行应该是总计的,但我不确定如何仅在 proc 报告中去除该行的格式:

Output

希望:总行不显示小数,因为它们是计数的,但表格的其余部分保持相同的格式。

    %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;

【问题讨论】:

  • 您无法使用 PROC REPORT 在列中轻松混合格式/分析。要么使用 PROC TABULATE,要么转置你想要的 PROC REPORT。
  • 我可以不为仅使用格式的行指定额外的调用定义函数吗?
  • 或者,我可以创建一个格式,因为所有未包含在总值行中的剩余值都小于 100,因为它们的总和为 100%?

标签: sas proc-report proc-format


【解决方案1】:

您必须明确格式化各个计算块中的数值。引用的数值取决于analysis 统计数据,语法为variable.statistic

您的数据(未显示)似乎是某种形式的预先计算的聚合,基于m_type = 'm_tot' 源代码。在这种情况下,引用类似于percentage16_1.sumsum 是指定分组时数字变量的默认analysis

例子:

总结一些 SASHELP.CARS 变量并更改 Ford 品牌的格式。

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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-20
    • 2020-10-19
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    相关资源
    最近更新 更多