1。建表
/*************************************/ /* create the second input data set */ /*************************************/ data patients; input ID $ 1-4 Name $ 6-16 Sex $ 18 Age 20-21 Date 23-24 Height 26-27 Weight 29-31 ActLevel $ 33-36 Fee 38-43; format fee 6.2; datalines; 2458 Murray, W M 27 1 72 168 HIGH 85.20 2462 Almers, C F 34 3 66 152 HIGH 124.80 2523 Johnson, R F 43 31 63 137 MOD 149.75 2539 LaMance, K M 51 4 71 158 LOW 124.80 2544 Jones, M M 29 6 76 193 HIGH 124.80 2552 Reberson, P F 32 9 67 151 MOD 149.75 2555 King, E M 35 13 70 173 MOD 149.75 2563 Pitts, D M 34 22 73 154 LOW 124.80 2571 Nunnelly, A F 44 19 66 140 HIGH 149.75 2572 Oberon, M F 28 17 62 118 LOW 85.20 2574 Peterson, V M 30 6 69 147 MOD 149.75 2575 Quigley, M F 40 8 69 163 HIGH 124.80 2578 Cameron, L M 47 5 72 173 MOD 124.80 2586 Derber, B M 25 23 75 188 HIGH 85.20 2588 Ivan, H F 22 20 63 139 LOW 85.20 2589 Wilcox, E F 41 16 67 141 HIGH 149.75 2595 Warren, C M 54 7 71 183 MOD 149.75 ; run;
2. 使用
/*************************************/ /* specify HTML output */ /*************************************/ ods html body='table.htm' style=default; /*************************************/ /* create a two-dimensional table */ /* with style elements specified */ /*************************************/ proc tabulate data=patients style=[font_weight=bold]; /*字体设置*/ class actlevel; /*要分类的字段名*/ classlev actlevel / style=[just=left]; /*指定样式元素*/ var age height weight / style=[font_size=3];/**/ keyword all sum / style=[font_width=wide]; keylabel all="All Patients"; table (actlevel="Activity Level" all*[style=[background=yellow]]), (age height weight*f=best10.2)*mean / style=[background=white] misstext=[label="Missing" style=[font_weight=light]] box=[label="Patient Info by Activity Level" style=[font_style=italic]]; title 'Enhanced Table'; run; /*************************************/ /* close the HTML destination */ /*************************************/ ods html close; /*************************************/ /* clear any titles in effect */ /*************************************/ title;
proc means data = patients n; var height; class actlevel; run;