自定义输出表以包含缺少的变量 [英] Customize Output Table to Include Missing Variable

查看:239
本文介绍了自定义输出表以包含缺少的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel文件,其中包含表壳(包括公式)和SAS的原始数据输出(如表1 =表壳;表2 =表1数据)的表格。



我试图更新表数据,而不必重新执行表shell和相应的公式。然而,对于时间序列,我有6个参与者组,但是一个没有在这个循环中报告数据。问题是缺少的组夹在中间,我不能将SAS输出粘贴到excel表。我想在结果中输出缺少的组,但是作为空白计数和百分比。



现在我正在做漂亮的标准 proc freq table var * Group / norow nocol 来获取计数和总计百分。

  Group 1 |第2组| ... |缺少组|第5组|组6 
N 500 303 475 630

提前感谢任何帮助!

解决方案

我不认为 PROC FREQ 可以做完全丢失列,不幸的是。 PROC TABULATE 可以像大多数具有CLASS变量的过程一样,在上使用 preloadfmt 语句和 printmiss 来告诉它创建所有的逻辑分组(这可能是危险的,所以在复杂的表上使用它谨慎) p>

  proc格式; 
value $ genderf
'M'='男'
'F'='女'
'T'='Trans'
;
退出;
proc tabulate data = sashelp.class;
class sex / preloadfmt;
var height;
格式sex $ genderf;
表sex,height * mean / printmiss;
运行;

唯一真正的方法是使其在 PROC FREQ 是对数据进行后处理(如果您正在查找数据集而不是打印输出),或者为您丢失的时间段添加一个虚拟行,这当然会改变您的结果。


I have an excel file with sheets that contain both the table shells (including formulas) and the raw data output from SAS (eg. Sheet 1 = Table Shell; Sheet 2 = Table 1 Data).

I am trying to update the table data without having to re-do the table shells and corresponding formulas. However, for the time series I have 6 participant groups, but one did not report data this cycle. The problem is that the missing group is sandwiched in the middle, and I can not paste the SAS output to the excel sheets. I want to output that missing group in the results but as blank counts and percents.

Right now I am doing pretty standard proc freq table var*Group/ norow nocol to get the count and total percent.

    Group 1 | Group 2 | ... | Missing Group | Group 5 | Group 6
N    500         303                           475        630
%    

Thanks in advance for any help!

解决方案

I don't think PROC FREQ can do an entirely missing column, unfortunately. PROC TABULATE can, as can most procedures that have a CLASS variable, using preloadfmt on the class statement and printmiss to tell it to create all logical groupings (which can be dangerous, so use it with caution on complicated tables).

proc format;
value $genderf
'M'='Male'
'F'='Female'
'T'='Trans'
;
quit;
proc tabulate data=sashelp.class;
class sex/preloadfmt;
var height;
format sex $genderf.;
tables sex,height*mean/printmiss;
run;

The only real way to make it work in PROC FREQ is to either postprocess the data (if you're looking for a dataset rather than a printed output), or to add a dummy row for your missing time period, which would of course alter your results.

这篇关于自定义输出表以包含缺少的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆