SAS proc report RTF表格列宽与指定宽度不对齐

SAS proc report RTF表格列宽与指定宽度不对齐,sas,report,rtf,ods,Sas,Report,Rtf,Ods,使用proc report以.rtf格式生成SAS表时,列宽未与其指定的宽度对齐。这会导致列标题占用多行,并截断一些值,这是我希望避免的 使用数据: /* Insert data */ data aaa; input cohort $ color $ sum $ pctn $; datalines; group_1 dark_yellow 2 12.500% group_2 orange 6 37.500% group_2 dark_green 8 50.000% o

使用proc report以.rtf格式生成SAS表时,列宽未与其指定的宽度对齐。这会导致列标题占用多行,并截断一些值,这是我希望避免的

使用数据:

/* Insert data */
data aaa;
   input cohort $ color $ sum $ pctn $;
   datalines;
group_1 dark_yellow 2   12.500%
group_2 orange  6   37.500%
group_2 dark_green  8   50.000%
overall orange  6   30.000%
overall dark_green  8   42.250%
;
run;
此代码用于生成列宽分别为7、11、16和30的.rtf文件:

/* Output settings */
options nocenter nodate nonumber missing=' ' orientation=landscape linesize=116 pagesize=42;    * page settings;
ods output close;       * close ods output;
ods rtf close;          * close ods rtf;
ods listing close;      * close ods listing;
footnote "Table generated on %sysfunc(date(), worddatx.w.)";            * insert date below report;
ods rtf file = "C:\Astudies\Colors.rtf" bodytitle;

/* Generate table */
proc report data=aaa nowd split='~';
column cohort color sum pctn;
define cohort   /order order=data       width=7     left    'Cohort';
define color        /display            width=11    left    'Color';
define sum          /display            width=16    left    'Number of colors';
define pctn         /display            width=30    left    'Percentage of total colors (%)';
title 'Painting';
title2'Common colours per cohort';
run;

title;              * remove any titles;
footnote;           * remove any footnotes;
ods rtf close;      * close ods rtf;
ods listing;
这将在下表中显示结果。第3-4列的标题跨越多行,其长度分别为16和30个字符。列2具有截断值,其中最大字符长度深黄色应为11

您可以在DEFINE column/style=[]选项中设置PROC REPORT column style width=属性

示例代码

本例假定10个景观房地产,相对无单元列宽为7、11、16和30。%SYSEVALF计算将相对宽度映射为ODS RTF渲染中使用的显式英寸

proc report data=aaa nowd split='~'
;
column cohort color sum pctn;
define cohort   /order order=data       left    'Cohort'                          style=[width=%sysevalf(10 *  7 / (7+11+16+30))in];
define color        /display            left    'Color'                           style=[width=%sysevalf(10 * 11 / (7+11+16+30))in];
define sum          /display            left    'Number of colors'                style=[width=%sysevalf(10 * 16 / (7+11+16+30))in];;
define pctn         /display            left    'Percentage of total colors (%)'  style=[width=%sysevalf(10 * 30 / (7+11+16+30))in];;
title 'Painting';
title2'Common colours per cohort';
run;

谢谢你的建议。使用此方法,我发现表列实际上太宽,明显比此处指向表的值和列标题链接都宽:。当使用其他数据进行测试时,尽管值和列标题没有占用那么多空间,但表不能放在纵向视图中。是否有一种方法可以更具体地根据表值和列标题来调整表长度?您是否尝试使用了width=,而不是使用相对列宽。直接进去?如果你想自动拟合列,考虑ODS Excel,而不是RTFNO确定你指的是什么。我以前直接使用了width=7 width=7,没有英寸这样的尺寸单位。示例代码公式分母将不带单位的宽度之和映射为10英寸,分子用于计算列的总宽度的小数部分。*10用于在横向页面中缩放到假定可用的不动产。使用宽度=7英寸或宽度=7英寸会产生错误。使用style=width=7in生成的列总体上比以前更不对齐。很遗憾,我需要以.rtf格式生成我的图表,但我确实喜欢您的Excel建议。