Excel 仅使用非缺失观测值填充特定范围的缺失值
嗨,我想知道如何将其放入SAS代码: 我的数据如下所示:Excel 仅使用非缺失观测值填充特定范围的缺失值,excel,sas,formula,Excel,Sas,Formula,嗨,我想知道如何将其放入SAS代码: 我的数据如下所示: Balance | Month | Outstanding --------+-------+-------------- 1000 | 0 | 200 | 1 | 300 | 2 | 400 | 3 | 500 | 4 | 800 | 5 | 750 | 6 | 650 | 7 | 740 | 8
Balance | Month | Outstanding
--------+-------+--------------
1000 | 0 |
200 | 1 |
300 | 2 |
400 | 3 |
500 | 4 |
800 | 5 |
750 | 6 |
650 | 7 |
740 | 8 |
580 | 9 |
650 | 10 |
523 | 11 | 7093
654 | 12 |
458 | 0 |
789 | 1 |
852 | 2 |
236 | 3 |
1258 | 4 |
4528 | 5 |
78520 | 6 |
1258 | 7 |
4821 | 8 |
15870 | 9 |
1587 | 10 |
1599 | 11 | 111776
6520 | 12 |
Balance | Month | Outstanding
--------+-------+------------
1000 | 0 | 7093
200 | 1 | 7093
300 | 2 | 7093
400 | 3 | 7093
500 | 4 | 7093
800 | 5 | 7093
750 | 6 | 7093
650 | 7 | 7093
740 | 8 | 7093
580 | 9 | 7093
650 | 10 | 7093
523 | 11 | 7093
654 | 12 | 7093
458 | 0 | 111776
789 | 1 | 111776
852 | 2 | 111776
236 | 3 | 111776
1258 | 4 | 111776
4528 | 5 | 111776
78520 | 6 | 111776
1258 | 7 | 111776
4821 | 8 | 111776
15870 | 9 | 111776
1587 | 10 | 111776
1599 | 11 | 111776
6520 | 12 | 111776
我希望它看起来像这样:
Balance | Month | Outstanding
--------+-------+--------------
1000 | 0 |
200 | 1 |
300 | 2 |
400 | 3 |
500 | 4 |
800 | 5 |
750 | 6 |
650 | 7 |
740 | 8 |
580 | 9 |
650 | 10 |
523 | 11 | 7093
654 | 12 |
458 | 0 |
789 | 1 |
852 | 2 |
236 | 3 |
1258 | 4 |
4528 | 5 |
78520 | 6 |
1258 | 7 |
4821 | 8 |
15870 | 9 |
1587 | 10 |
1599 | 11 | 111776
6520 | 12 |
Balance | Month | Outstanding
--------+-------+------------
1000 | 0 | 7093
200 | 1 | 7093
300 | 2 | 7093
400 | 3 | 7093
500 | 4 | 7093
800 | 5 | 7093
750 | 6 | 7093
650 | 7 | 7093
740 | 8 | 7093
580 | 9 | 7093
650 | 10 | 7093
523 | 11 | 7093
654 | 12 | 7093
458 | 0 | 111776
789 | 1 | 111776
852 | 2 | 111776
236 | 3 | 111776
1258 | 4 | 111776
4528 | 5 | 111776
78520 | 6 | 111776
1258 | 7 | 111776
4821 | 8 | 111776
15870 | 9 | 111776
1587 | 10 | 111776
1599 | 11 | 111776
6520 | 12 | 111776
基本上,我想用第0-11个月的余额之和填充整个第0-12个月范围内的空单元格,并对下一组第0-12个月进行填充
在Excel中,我可以使用这个公式来实现这一点。在此假设余额的列号为A,月份为B,未付金额为C:
=IF(B2=0,SUM(A2:A13),C1)
然后向下拖动移动和的公式
我只是不知道如何在SAS代码中创建等效代码 移动求和可以通过
PROC EXPAND
:
proc expand data=have
out=want;
by <by variables>;
convert balance = outstanding / transform=(movsum 12);
run;
proc expand data=have
出去=需要;
通过
转换余额=未偿/转换=(movsum 12);
跑
您的问题不完全清楚,需要重新格式化,但
proc expand
将执行您想要的操作。您可以阅读上的语法。我已将输入数据设置为:
data have;
input balance month outstanding;
datalines;
1000 0 .
200 1 .
300 2 .
400 3 .
500 4 .
800 5 .
750 6 .
650 7 .
740 8 .
580 9 .
650 10 .
523 11 7093
654 12 .
458 0 .
789 1 .
852 2 .
236 3 .
1258 4 .
4528 5 .
78520 6 .
1258 7 .
4821 8 .
15870 9 .
1587 10 .
1599 11 111776
6520 12 .
;
您可以将数据与自身组合,以获得所需的结果,如下所示:
data want;
set have(where=(outstanding ne .));
do until (month=12);
set have(drop=outstanding);
output;
end;
run;
您好,我尝试使用proc expand,但是,我希望所有单元格都具有相似的值,而不是累积总数。你知道我该怎么做吗?谢谢