proc report 一二三事:循環輸出,分情況輸出,加橫線、加文本信息、加空白行及寬度設置


輸出output的時候,因某些原因,例如不同組別的某些情況不一樣,則需要分開輸出,有規律的可以使用%do循環,沒規律的可以使用%if分情況輸出:

對於按照分組來proc report的table,每個組具有不同的N,則應該每個組循環report,用不同的每個組不同的N值放在表頭位置。采用循環的方式———>在宏程序中使用do循環,制造宏變量i來引用。
%macro report;
options papersize=letter orientation=landscape nodate nonumber center missing=" " nobyline;
ods escapechar="@";
ods listing close;

%do i=1 %to 4;
proc report data = final (where=(agegr2n=&i.)) missing nowd headline headskip nocenter spacing = 2 split = "~";
 column……("Completion/Discontinuation @R/RTF'\fs0\brdrb\brdrs\brdrw10\qc" col4 col5);
 note:brdrw10是header那一欄分割線的寬度,qc表示居中顯示,ql表示居左顯示;col4和col5共同擁有header "Completion/Discontinuation"

                    
 define……;
 define col2/display "Placebo ->~SD-101-6.0~(N=&&x&i)~n (%)"       &line. style(column)=[cellwidth=21.5% just=c asis=on]   style(header)=[just=c] ;
 define col3/display "SD-101-6.0 ->~SD-101-6.0~(N=&&y&i)~n (%)"  &line. style(column)=[cellwidth=21.5% just=c asis=on]   style(header)=[just=c] ;
 define col4/display "Total~(N=&&z&i)~n (%)"                                     &line. style(column)=[cellwidth=21.5% just=c asis=on]   style(header)=[just=c] ;
 break after page/page ;                   
 compute after seq;
  line '@\fs6';               note:每個小組數之間加空行,包括空行寬度
 endcomp;                                     

 compute after _page_;
  line &line;                  note: 頁后加橫線
 endcomp;              

compute before _page_ /left;
  text="Age group: "||strip(col0);       
  line @1 text $100.;    note:頁前加橫線,頁前加分組信息文本內容  
  line &line.; 
endcomp;                                     
%end;
run;


ods rtf close;
ods listing;
%mend report;                       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM