0

我有一个问题,通过 do 循环创建我的报告,但是列出宏的标题页每次都没有反映正确的命名约定。它适用于 PDF 中的每个书签以及 proc 报告本身。但是标题没有正确反映。

%macro PDF_T2(year=,  age= );

proc sql noprint;
select distinct region,  bh_type
      into :region1 - :region14, :bh_type1 -  :bh_type14
      from table2_IP
;
quit;

/*%put &region1 &region2;*/
/*%put &bh_type1 &bh_type2;*/

ods escapechar '^';
ods pdf file="C:\PDFS\Table2.pdf" pdftoc=2 style=Custom;

options orientation=landscape missing=' '

topmargin=.25in 
bottommargin=.25in
leftmargin=.25in rightmargin=.25in ;

ods proclabel " Inpatient Analysis By Plan ";


%do i=1 %to 4;


TITLE  "^{style [JUST= C ]Table 2. Inpatient Utilization By Plan,}";
TITLE2 "^{style [JUST= C ]&&region&i.  }" ;
Title3 "^{style [JUST= C ]Adult (21 to 64)}";
Title4 "^{style [JUST= C ]&&bh_type&i. Analysis}"  ;

PROC REPORT DATA =  Table2_IP contents="&&bh_type&i. Table: Inpatient`enter code here`
4

1 回答 1

1

我会尝试确保您使用的是 %local 宏变量。如果您有浮动的全局宏变量,可能会导致一些令人惊讶的结果。

我还会打开 MPRINT 并查看日志以查看正在生成的代码。它将显示宏正在生成的 TITLE 语句。

标题不会自行清除,但每次执行 TITLE 语句时,它都会清除所有现有标题。

我稍微修改了您的代码以在 sashelp.prdsale 上工作,看起来还不错:

%macro titletest(dummy);
%local i region1 region2;

proc sql noprint;
select distinct region
      into :region1 - :region2
      from sashelp.prdsale
;
quit;

%put region1=&region1 region2=&region2;

%do i=1 %to 2;
  title1 "Results for &&region&i";
  proc print data=sashelp.prdsale;
    where region="&&region&i";
  run;
  title1;
%end;

%mend;

options mprint;
%titletest()
于 2016-02-19T15:08:10.437 回答