思路:
1、导入数据
data work.a;
LENGTH companyId 8 sasDate 8 sasTime 8 accumulateQty 8 exchangeQty 8 exchangePrice 8 time 8;
infile datalines delimiter=' ';
input companyId sasDate sasTime accumulateQty exchangeQty exchangePrice time:TIME.;
datalines;
1102 15614 33241 100 37 9 09:14
1102 15614 33441 101 1 9 09:17
1102 15614 33561 102 1 9.05 09:19
1102 15614 34002 103 1 9.05 09:27
1102 15614 34082 108 5 9.1 09:28
1102 15614 34122 109 1 9.1 09:29
1102 15614 34162 110 1 9.15 09:30
1102 15614 34242 113 3 9.15 09:31
1102 15614 34322 134 21 9.15 09:32
1102 15614 34362 136 2 9.2 09:33
1102 15614 34442 149 13 9.2 09:34
1102 15614 34482 153 4 9.2 09:35
1102 15614 34522 173 20 9.15 09:36
1102 15614 34642 174 1 9.15 09:37
1102 15614 34842 179 5 9.15 09:41
1102 15614 35242 181 2 9.2 09:47
1102 15614 35282 192 11 9.2 09:48
1102 15614 35642 193 1 9.2 09:54
1102 15614 35722 194 1 9.2 09:55
1102 15614 35762 195 1 9.25 09:56
1102 15614 35802 204 9 9.25 09:57
;
run;
2、在原来的数据中增加一新变量,变量代表时间区间。
data b;
set a;
if time>=32400 and <=32700 then time1=1;
if time>=37600 and <=40000 then time1=2;
...
....
....
..
if time>=35760 and <=36000 then time1=n;
run;
3、以time1作为分类变量,分别对exchangeqty 和exchangeprice汇总。
proc means data=b n sum;
var exchangeqty exchangeprice;
class time1;
output out=c sum(exchangeqty)= sum(exchangeprice)=;
run;