13# funwin
sorry, that is my fault.
我假设你的return 类似于以前的company。
*读入excel数据;
PROC IMPORT OUT= WORK.tab
DATAFILE= "C:\YourBook.xls" *your excel table;
DBMS=EXCEL REPLACE;
RANGE="Sheet1$";
GETNAMES=YES;*第一行留作sas变量名;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
data tab_;
set tab;
array dt{*} _:;*因为读入的变量以在excel中以数字开头,sas缺省性地改变第一个数字为‘_', 这也是为什么可以方便地用'_:'(以'_'开头的所有变量),也就是说在此数据里如果一些无关的变量也以’_'开头,就会有错误;
do i=1 to dim(Dt);
company=return;*company只是名字,随便叫;
date_=input(substrn(vname(Dt{i}),3), yymmdd10.);*应该从第三个字母截起,也是我上面的错误;
var=dt{i};
output;
end;
format date_ date9.;
keep company date_ var;*只保留你感兴趣的;
run;
*since your excel tables are similar, it should be better to use a macro rather than repeatedly use similar data steps and import procedures,to tackle this problem;
on the other hand, writing that one by one is readable and doable;