我有以下宏:遍历列表
rsubmit;
data indexsecid;
input secid 1-6;
datalines;
108105
109764
102456
102480
101499
102434
107880
run;
%let endyear = 2014;
%macro getvols1;
* First I extract the secids for all the options given a date and
an expiry date;
%do yearnum = 1996 %to &endyear;
proc sql;
create table volsurface1&yearnum as
select a.secid, a.date, a.days, a.delta, a.impl_volatility,
a.impl_strike, a.cp_flag
from optionm.vsurfd&yearnum as a, indexsecid as b
where a.secid=b
and a.impl_strike NE -99.99
order by a.date, a.secid, a.impl_strike;
quit;
%if &yearnum > 1996 %then %do;
proc append base= volsurface11996 data=volsurface1&yearnum;
run;
%end;
%end;
%mend;
%getvols1;
proc download data=volsurface11996;
run;
endrsubmit;
data _null_;
set work.volsurface11996;
length fv $ 200;
fv = "C:\Users\user\Desktop\" || TRIM(put(indexsecid,4.)) || ".csv";
file write filevar=fv dsd dlm=',' lrecl=32000 ;
put (_all_) (:);
run;
在上面的代码我有:其中a.secid = 108105。现在我列出了几个secid的列表,我需要为每个secid运行一次宏。我正在运行一次,并为每个secid生成一个新的数据集。 我该怎么做?由于
为什么你想要每secid生成一个数据集?通常将所有内容都保存在一个大数据集中并使用按组处理更简单。 – user667489 2015-04-01 12:28:44
好吧,我想将它导出为CSV,然后在matlab中读取它,如果我对每个secid都有一个CSV文件,它对我来说更容易。 – phdstudent 2015-04-01 12:32:07
列表中有多少个secid值?你想要在另一个数据集中存在的所有值吗? – user667489 2015-04-01 12:40:41