????????臨床統(tǒng)計分析中的報表經(jīng)常以如下的樣式出現(xiàn)咨察,如果生成這樣的表格论熙,可能有很多種方法「G啵現(xiàn)在說一種本人工作中用的方法。
測試數(shù)據(jù)集就用SASHELP.class.
proc sort data=sashelp.class out=a;by sex name;run;
先定義輸出的RTF模板,定義如下(ps,模板如果沒定義好无午,出報告中的某些代碼可能不會起作用媒役,具體是哪方面原因還沒弄明白)。
proc template;
define style tfl_table;
style body/
leftmargin = 0.5in
rightmargin = 0.5in
topmargin = 1in
bottommargin = 1in;
style table /
frame = hsides
rules = groups
cellpadding = 3pt
cellspacing = 0pt
width = 100%;
style header /
fontfamily = 'Courier New'
asis = off
fontsize = 9pt;
style data /
fontfamily = 'Courier New'
fontsize = 9pt
asis = on;
style TableFooterContainer /
borderbottomcolor = white;
style TitlesAndFooters /
fontfamily = 'Courier New'
textalign = left
fontsize = 10pt;
style systemfooter /
textalign = left
fontfamily = 'Courier New'
fontsize = 9pt;
style NoteContent from Note /
textalign = left
fontsize = 9pt
fontfamily = 'Courier New'
asis = on;
end;
run;
用PROC REPORT 過程步輸出RTF的代碼如下:
options orientation=portrait nodate nonumber;
ods escapechar='^';
ods rtf file = "d:\test.rtf" style=tfl_table;
footnote "^{super a} : This is done by kongyy";
proc report nowindows data=a;
column sex name ("Sex" header) ("^R'\brdrb\brdrs\brdrw2 'Wonder Treatment" weight height);
define sex /order noprint;
define name /noprint;
define header /'' computed;
define weight / display 'weight' format=8.1 style={just=r};
define height / display 'height' format=8.1 style={just=r};
break before sex /summarize ;
compute header / character length = 20;
if _break_ = 'Sex' then header = Sex;
else header = "^{nbspace 3}"||name;
endcomp;
run;
ods rtf close;
假如要使weight 和 height中的數(shù)值小數(shù)點位對齊的話宪迟,則可使用style來定義酣衷。代碼如下:
define weight / display 'weight' format=8.1 style={pretext="^R'\tqdec\tx350 '" just=r};
define height / display 'height' format=8.1 style={pretext="^R'\tqdec\tx350 '" just=r};
除了以上方法產(chǎn)生縮進RTF外,還可以用^w產(chǎn)生空格的效果, ^ 這個為自定義的ods escapechar.
compute header / character length = 20;
if _break_ = 'Sex' then header = Sex;
else header = "^w^w^w^w"||name;
endcomp;
好了次泽,以上就是我想分享的穿仪,更多的輸出格式控制技巧,以后有空再探索意荤。謝謝啊片。