请大家帮忙看看我这个程序,我想生成100个sample,每个sample100只股票。一只股票要选进一个sample必须满足几个条件(主要由下面的几个where和if完成),可是这个k并没有帮我完成计数的功能,请问该如何修改?谢谢了!
%macro sample_construction;
%do i=1 %to 100;
%do %until (namesample&i.k=100);
data number;
number=ceil(120*uniform(-123));
run;
proc sql;
create table evntmon as
select date as evntmon
from kw.evntper as a, number as b
where a.j=b.number;
run;
proc surveyselect data=kw.name method = urs sampsize =1
rep=1 out=tempname noprint;
id cusip;
run;
proc sql;
create table comp as
select a.cusip, m as l, c.evntmon
from kw.nyam_new as a, tempname as b, evntmon as c
where a.cusip=b.cusip and a.date=c.evntmon;
quit;
proc sql;
create table work.tempobs as
select a.*, b.evntmon
from kw.nyam_new as a, comp as b
where a.cusip=b.cusip;
quit;
data _null_;
set tempobs comp;
if m=l-24 then call symput(id, cusip);
run;
data namesample&i;
set namesample&i comp;
if cusip=id then k=k+1;
run;
%end;
proc sql;
create table kw.newsample&i as
select a.*, b.evntmon
from kw.nyam_new as a, work.namesample&i as b
where a.cusip=b.cusip;
quit;
%end;
%mend sample_construction;
%sample_construction;