楼主: tagv
4040 35

请大家帮个忙,看看这个表怎么编? [推广有奖]

31
tagv 发表于 2009-8-26 15:49:45
我现在对那个retain 开始小心了

32
tagv 发表于 2009-8-26 15:52:03
我先谢了。明天聊!有可能的话,帮我看看我的那堆垃圾 主要错在那里!我又死不瞑目的感觉!哭死。。。

33
jingju11 发表于 2009-8-26 23:57:40
data a;
input price time_record;
cards;
51        41334               
51        41336           
51        41337            
51        41342        
51        41344        
51        41351            
51        41361              
51        41368
52        41372
51        41383
53        41383  
;
run;

%macro RMrecords(s=5);*s should be an integer;
%local i;
%let i=1;
proc sort data=a out=As; by Time_record; run;
%do%while(&i le &s.);
data As;
set As;
lagTradeTime=dif(Time_record);
if missing(lagTradeTime) then lagTradeTime=999;
run;
proc sql noprint;
select min(lagTradeTime) into :i  from As;
quit;
%put &i;
%if &i gt &s. %then %goto EndL;
data As;
set As;
Lag2TradeTime=lag(LagTradeTime);
if ^(Lag2TradeTime gt &s. & LagTradeTime le &s.);
drop Lag2TradeTime;
run;
%EndL: ;
%end;
%mend RMrecords;
%RMrecords
;
proc print;run;

34
jingju11 发表于 2009-8-27 05:25:50
32# tagv

data a;
do time_record=1 to 1000;
output;
end;
run;

%macro RMrecords(s=5);*s should be an integer;
%local i;%let i=1;
proc sort data=a out=As nodupkey; by Time_record; run;
%do%while(&i le &s.);
data As;
set As;
retain s 0;
m=dif(Time_record);
if missing(m) or m>5 then m=0;
if m then s+m;  else s=0;
if ^s or s>5 ;*keep those s>5,保证正确地的删除;
drop  m s;
run;
data final;
set As;
lagTradeTime=dif(Time_record);
run;
proc sql noprint;
select min(lagTradeTime) into :i  from Final;
quit; *不断地估计i,保证循环;
%put &i;
%end;
%mend RMrecords;
%RMrecords
;
proc print;run;

从sushe的程序而来 这个应该有效些;

35
tagv 发表于 2009-8-27 07:02:04
非常感激!我正在读。有问题接着请教 ,,,

36
tagv 发表于 2009-8-27 07:02:45
再出个新的动态的难题。。。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-23 09:39