我的原始文件是这样按时间段划分的:
Period P1 P2 P3 P4 P5 P6 P7
03/01/2013 to 06/01/2013 31.0 16.5 28.7 18.1 23.4 16 12.0
07/01/2013 to 09/01/2013 31.0 18.0 29.3 19.2 24.3 13 3.6
但是,该文件有很多行,我需要这些文件保持原样:
Period P1 P2 P3 P4 P5 P6 P7
03/01/2013 31.0 16.5 28.7 18.1 23.4 16 12.0
04/01/2013 31.0 16.5 28.7 18.1 23.4 16 12.0
05/01/2013 31.0 16.5 28.7 18.1 23.4 16 12.0
06/01/2013 31.0 16.5 28.7 18.1 23.4 16 12.0
07/01/2013 31.0 18.0 29.3 19.2 24.3 13 3.6
08/01/2013 31.0 18.0 29.3 19.2 24.3 13 3.6
09/01/2013 31.0 18.0 29.3 19.2 24.3 13 3.6
有谁知道如何使用 sas 或 linux 以实用的方式做到这一点?
最佳答案
只需使用 DO 循环。您可以使用 INTCK()
函数了解迭代次数,并使用 INTNX()
函数计算新的日期值。
这是您的示例数据。
data have;
length Start Stop P1-P7 8;
informat Start Stop mmddyy.;
format Start Stop yymmdd10.;
input start stop p1-p7;
cards;
03/01/2013 06/01/2013 31.0 16.5 28.7 18.1 23.4 16 12.0
07/01/2013 09/01/2013 31.0 18.0 29.3 19.2 24.3 13 3.6
;;;;
现在写一个新的数据步骤来扩展行数。
data want;
format period yymmdd10.;
set have ;
do offset=0 to intck('month',start,stop);
period = intnx('month',start,offset);
output;
end;
run;
关于linux - 如何使用 sas 或 linux 分隔文件中的句点和复制行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38509637/