Proc报告书ODS中的标题PDF

时间:2016-02-12 13:34:28

标签: sas ods proc-report

我希望让ODS PDF中的每个proc报告在PDF书签的第三层都有自己的指定标题。我怎样才能实现这个概念?例如,在下图中,我想将“表1”条目更改为其他文本。

enter image description here

我的代码如下:

ods escapechar '^';
ods pdf file='S:\Restricted\CITER-ER\BHO Phase II\Transition Monitoring\2. Service Utilization\2. Production\SAS codes\Tinkler\PDF Project\SAS REPORTS PDF\PDFS\table2.pdf' style=Custom;

TITLE  "^{style [JUST= C ]Table 2. Names , 2014}";
TITLE2 "^{style [JUST= C ]State}" ;
Title3 "^{style [JUST= C ]Adult (21 to 64)}";
Title4 "^{style [JUST= C ] Analysis}"  ; 
options orientation=landscape nocenter 
topmargin=.25in 
bottommargin=.25in
leftmargin=.25in rightmargin=.25in ;
ods proclabel "IP"; 
PROC REPORT DATA = Table2x
    style(report)={font_size=9pt cellpadding=2pt cellspacing=.15pt}
    style(header)={background=VLIG foreground=black font_size = 9pt FONT_WEIGHT = bold  just=C }
    style(column)={font_size=8pt just=C}
    STYLE(SUMMARY) = {font_weight=bold};
    WHERE BH_Type = 'MH'  ;
    COLUMN (
       (' ' P_type  )
       (' ' P_name )
       ('MH Inpatient Volume'   AID_Type
        UNIQUSERS  N_Episode  Admis_Tot    Disc_Tot  AvgLOS medianLOS  LOS_C   LOS   T_AMT_PAID  
           AvgCostUser      AvgCostEnc ) );
        Define P_Type /      'MMC Program or Coverage Type'  group  order=data      style(column)= { cellwidth=20mm  just=L    }  ; 
        Define P_name /    'Plan Name or Coverage Type'      group  order=data      style(column)= { cellwidth=30mm    just=L        }  ; 
        Define AID_Type/  'Aid Category'                                                        style(column)= { cellwidth=20mm}  ;         
        Define UNIQUSERS  /    'Unique Users'                               FORMAT=COMMA12.0    style(column)= { tagattr='format:###,###,##0'     cellwidth=20mm}   ;
        Define N_Episode  /    '# of Episodes^{super 1}'                        FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'  cellwidth=20mm}  ;
        Define Admis_Tot    /    'Admissions^{super 2}'                     FORMAT=COMMA12.     style(column)= { tagattr='format:###,###,##0'   cellwidth=20mm}    Style(header)={FONT_WEIGHT = bold}       ;
        Define Disc_Tot   /      'Discharges^{super 2}'                     FORMAT=COMMA12.     style(column)= { tagattr='format:###,###,##0'   cellwidth=20mm}     Style(header)={FONT_WEIGHT = bold}      ;
        Define LOS_C  /    'Hospital Days^{super X}'        Noprint         FORMAT=COMMA12.     style(column)= { tagattr='format:###,###,##0'    cellwidth=15mm}    Style(header)={FONT_WEIGHT = bold} ;
        DEFINE LOS  /   'LOS for discharged^{super 4}'      Noprint         FORMAT=COMMA12.     style(column)= { tagattr='format:###,###,##0'  cellwidth=20mm}      Style(header)={FONT_WEIGHT = bold} ;
        Define T_AMT_PAID    /    'Total Amount Paid,$'                         FORMAT=DOLLAR14. style(column)= { tagattr='format:$###,###,###'    cellwidth=20mm}  Style(header)={FONT_WEIGHT = bold} ;
        Define AVGCOSTUSER    /    'Avg Cost Per User, $'                   FORMAT=DOLLAR14. style(column)= { tagattr='format:$###,###,###'    cellwidth=20mm} ;
        Define AvgLOS     /     'Mean LOS for Discharged Episode'           FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'    cellwidth=20mm}    ;
        DEFINE MEDIANLOS  /     'Median LOS for Discharged Episode'          FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'    cellwidth=20mm}   ;
        Define AVGCOSTENC     /    'Avg. Cost Per Episode, $'                   FORMAT=DOLLAR14. style(column)= { tagattr='format:$###,###,###'    cellwidth=20mm} ;


/* compute P_type;*/
/* if P_Type = 'Total'  THEN   call define(_row_,'style','style={background=VLIP   just=R}'); */
/**/
/* end;*/
/* endcomp;*/

compute P_type;
bg + 1;
if mod(bg, 2) = 1 then
call define(_row_, "style", "style={background=white}");
ELSE call define(_row_, "style", "style={background=#d1e9d1}");
IF  P_Type = 'Total'  THEN   call define(_row_,'style','style={background=VLIP   just=R}');
endcomp;

RUN;

/*Need New Title*/

PROC REPORT DATA = Table2x
    STYLE(header) = {background=VLIG foreground=black font_size = 10pt
                    FONT_WEIGHT = bold  just=C}
    STYLE(column) = {font_size = 12pt  just=R}
    STYLE(SUMMARY) = {font_weight=bold};
    WHERE BH_Type = 'SUD'   ; 
    COLUMN (
       (' ' Year_Month )
       ( ' ' P_type  )
       (' '  P_name )
       ('SUD Inpatient Volume'   AID_Type
        UNIQUSERS  N_Episode  Admis_Tot    Disc_Tot  AvgLOS medianLOS  LOS_C   LOS   T_AMT_PAID  
           AvgCostUser      AvgCostEnc ) );
        DEFINE YEAR_MONTH /   'YEAR and Month'                       style(column)= { cellwidth=20mm  just=L    }  ;
        Define P_Type /      'MMC Program or Coverage Type'                 style(column)= { cellwidth=20mm  just=L    }  ; 
        Define P_name /    'Plan Name or Coverage Type'                       style(column)= { cellwidth=50mm    just=L        }  ; 
        Define AID_Type/  'Aid Category'                                             style(column)= { cellwidth=20mm}  ;        
        Define UNIQUSERS  /    'Unique Users'                               FORMAT=COMMA12.0 style(column)= { tagattr='format:###,###,##0'     cellwidth=20mm}  ;
        Define N_Episode  /    '# of Episodes~{super 1}'                        FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'  cellwidth=20mm}  ;
        Define Admis_Tot    /    'Admissions~{super 2}'                     FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'   cellwidth=20mm}    Style(header)={FONT_WEIGHT = bold}       ;
        Define Disc_Tot   /      'Discharges ~{super 2}'                    FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'   cellwidth=20mm}     Style(header)={FONT_WEIGHT = bold}      ;
        Define LOS_C  /    'Hospital Days~{super X}'        Noprint         FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'    cellwidth=15mm}    Style(header)={FONT_WEIGHT = bold} ;
        DEFINE LOS  /   'LOS for discharged~{super 4}'      Noprint         FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'  cellwidth=20mm}      Style(header)={FONT_WEIGHT = bold} ;
        Define T_AMT_PAID    /    'Total Amount Paid,$'                         FORMAT=DOLLAR14. style(column)= { tagattr='format:$###,###,###'    cellwidth=20mm}  Style(header)={FONT_WEIGHT = bold} ;
        Define AVGCOSTUSER    /    'Avg Cost Per User, $'                   FORMAT=DOLLAR14. style(column)= { tagattr='format:$###,###,###'    cellwidth=20mm} ;
        Define AvgLOS     /     'Mean LOS for Discharged Episode'           FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'    cellwidth=20mm}    ;
        DEFINE MEDIANLOS  /     'Median LOS for Discharged Episode'          FORMAT=COMMA12. style(column)= { tagattr='format:###,###,##0'    cellwidth=20mm}   ;
        Define AVGCOSTENC     /    'Avg. Cost Per Episode, $'                   FORMAT=DOLLAR14. style(column)= { tagattr='format:$###,###,###'    cellwidth=20mm} ;


 compute P_type;
 if P_Type = 'Total'  THEN   call define(_row_,'style','style={background=VLIP   just=R}'); 
 endcomp;

RUN;












ods pdf close; 

1 个答案:

答案 0 :(得分:1)

添加标题就像将另一个标题命令放在您想要的位置一样简单。它只能在proc运行之间更改,但在上面的情况下,这不是问题。

如果要更改书签标题,请使用ods proclabel,也可以在运行之间更新。

如果您想更改二级书签列表,请使用contents中的PROC REPORT选项。

如果您想更改第三级书签列表,请使用contents语句中的pagedefine选项。

ods pdf file="c:\temp\test.pdf";
title "First Run";
ods proclabel="Age";
proc report data=sashelp.class contents="Table Grouped by Age";
  columns age height weight;
  define age/group contents='Table Grouped by Age' page;
  define height/analysis mean;
  define weight/analysis mean;
run;

title "Second Run";
ods proclabel="Sex";
proc report data=sashelp.class contents="Table Grouped by Sex";
  columns sex height weight;
  define sex/group contents='Table Grouped by Sex' page;;
  define height/analysis mean;
  define weight/analysis mean;
run;

title;

ods pdf close;