d*******8 发帖数: 321 | 1 业余时间学了些SAS,有些简单问题向大家请教。
我有很多SAS DATA 文件,dat1, dat2.... 这些文件结构相同。现在需要把这些文件转
换合并成一个SAS DATASET。最简单的方法就是:
data alldata;
set dat1 dat2.....;
run;
但是文件太多了, 我现在用一个文件(filenames)去记录所有文件名:
names |
R*********i 发帖数: 7643 | 2 You can't use a procedure within a data step. And you can't use "set" to
pull in an external file. Please refer to the Little SAS book for
fundamental concepts. |
d*******8 发帖数: 321 | |
R*********i 发帖数: 7643 | 4 Not "老手" or "前辈", just know some SAS coding.
Assume all your datasets are already in working directory, and "filenames"
is a .txt file.
data names;
infile "XXXX\XXXX\filenames";
input name $;
run;
proc sql noprint;
select name into: names seperatedby " "
from names;
quit;
data alldata;
set &names;
run;
There's a limit for the length of macro variable. So if your file names are
too long or you have more than several thousands files you will have to use
more than one macro variable to hold the names. |
d*******8 发帖数: 321 | 5 太感谢了,除了little sas book, 能否推荐一本好的SAS程序书,好像little sas 的
内容很简单。 |
l**********9 发帖数: 148 | 6 如果不嫌麻烦,在原文件中添加分隔符的话,直接infile.....dsd 或者用(dlm)就可
以。 |
R*********i 发帖数: 7643 | 7 It sounds like you haven't goon through the Little SAS Book thoroughly. :-)
You can always refer to the SAS online doc http://support.sas.com/onlinedoc/913/docMainpage.jsp, and the SUG/PharmaSUG papers.
【在 d*******8 的大作中提到】 : 太感谢了,除了little sas book, 能否推荐一本好的SAS程序书,好像little sas 的 : 内容很简单。
|