W*****r 发帖数: 193 | 1 用各个csv的id合并起来
简单的的我知道怎么做
比如
proc import datafile="D:file1.csv"
out=new1 dbms=csv replace; getnames=yes;
run;
proc print data=new1;
run;
proc import datafile="D:file2.csv"
out=new2 dbms=csv replace; getnames=yes;
run;
proc print data=new2;
run;
data dn;
merge new1 new2;
by id;
run;
文件“dn”含new1 和 new2的所有variables, 使用公用的id
问题是,如果csv files很多怎么办?比如100+?
可不可以用proc sql + Macro做出来?
怎么做?
多谢。 |
b*****s 发帖数: 11267 | |
f*******m 发帖数: 94 | |
W*****r 发帖数: 193 | 4 不会unix
个文件?
【在 b*****s 的大作中提到】 : 折腾,unix命令就可以
|
W*****r 发帖数: 193 | 5 好的
我看看,多谢
【在 f*******m 的大作中提到】 : see here: : https://communities.sas.com/t5/Base-SAS-Programming/Help-merging-multiple- : CSV-files-to-a-dataset/td-p/184804
|
W*****r 发帖数: 193 | 6 有点没看明白
比如5个csv files(文件名叫dr1.csv, dr2.csv,...,dr5.csv) 在 d:\filename\文件夹下
下面的code应该怎么改?
%macro multimp(dir=,out=);
* Make sure output ds does not exist ;
proc delete data=&out; run;
* Read list of filenames and generate PROC IMPORT and PROC APPEND for each one ;
filename code temp ;
data _null_ ;
infile "dir ""&dir\btlt4-*.csv"" /b" pipe truncover;
input filename $256.;
file code ;
put 'proc import datafile="&dir\' filename +(-1) '" out=onefile replace;'
/ 'run;'
/ 'proc append data=onefile base=&out force; run;'
;
run;
* Run the generated code ;
%inc code / source2 ;
%mend multimp ;
【在 f*******m 的大作中提到】 : see here: : https://communities.sas.com/t5/Base-SAS-Programming/Help-merging-multiple- : CSV-files-to-a-dataset/td-p/184804
|