h***b 发帖数: 43 | 1 大家春节好啊!请教个问题,提前谢谢阿!
我有10个文件,文件名abc01,abc02,。。。,abc10代表01年到10年的10年记录,如
果我按照下面这样写, do i = 01 to 10,SAS读到的文件就成了abc1,abc2...,那个0读
不到,也就是前九个文件都无法读了。那位大侠给个code写法啊,谢谢啦!
%macro OTPT();
%do i= 01 %to 10;
data final&i;
set abc&i;
.
.
.
.
.
%end;
%mend;
%OTPT();
run; | A*****a 发帖数: 1091 | 2 %macro test;
%do i=1 %to 10;
%let val=%sysfunc(putn(&i,z2.));
%put &val;
%end;
%mend;
%test
【在 h***b 的大作中提到】 : 大家春节好啊!请教个问题,提前谢谢阿! : 我有10个文件,文件名abc01,abc02,。。。,abc10代表01年到10年的10年记录,如 : 果我按照下面这样写, do i = 01 to 10,SAS读到的文件就成了abc1,abc2...,那个0读 : 不到,也就是前九个文件都无法读了。那位大侠给个code写法啊,谢谢啦! : %macro OTPT(); : %do i= 01 %to 10; : data final&i; : set abc&i; : . : .
| h***b 发帖数: 43 | 3 Thanks much Archaea!I tried as the following, but it still can not read the
"0". It shows file in.abc1 does not exist, and so on for other files.
%macro test;
%do i=1 %to 10;
%let val=%sysfunc(putn(&i,z2.));
%put &val;
data abc20&i.;
set in.abc&i.;
run;
%end;
%mend;
%test | c*********u 发帖数: 607 | | A*****a 发帖数: 1091 | 5 应该用:
%macro test;
%do i=1 %to 10;
%let val=%sysfunc(putn(&i,z2.));
data abc20&val.;
set in.abc&val.;
run;
%end;
%mend;
%test
the
【在 h***b 的大作中提到】 : Thanks much Archaea!I tried as the following, but it still can not read the : "0". It shows file in.abc1 does not exist, and so on for other files. : %macro test; : : %do i=1 %to 10; : %let val=%sysfunc(putn(&i,z2.)); : %put &val; : data abc20&i.; : set in.abc&i.; : run;
| h***b 发帖数: 43 | 6 It works. Thanks Archaea! | N***3 发帖数: 801 | 7 如果做时间序列可以这样写
%macro loop;
%do i=1 %to 20;
data _null_;
monyy=intnx('month','01dec1999'd,&i);
call symput('yymm',put(monyy,yymmn4.));
run;
proc sql;
create table a_&&yymm as
select put(&&yymm,z4.) as yymm, * from sashelp.cars;
quit;
proc append base=master data=a_&&yymm;
run;
%end;
%mend;
%loop; |
|