Hi, If you want to try my code, first save the text below to c:\temp as 20120101_testdate.txt 20120201_testdate.txt 20120301_testdate.txt Region~State~Month~Expenses~Revenue Southern~GA~JAN97~2000~8000 Southern~GA~FEB97~1200~6000 Southern~FL~FEB97~8500~11000 Northern~NY~FEB97~3000~4000 Northern~NY~MAR97~6000~5000 Southern~FL~MAR97~9800~13500 Northern~MA~MAR97~1500~1000 /*After run my code, you should have 3 datasets _20120101_testdate.sas7bdat, _20120201_testdate.sas7bdat, _20120301_testdate.sas7bdat Created in your work library.*/ %macro test(location);/* location is where the files are stored */ filename indata pipe "dir &location.\*.txt /b"; /*find the files*/ data files; length in_name out_name $32; infile indata truncover; input in_name $32.; /* input the file names */ out_name=cats('_',scan(in_name,1,'.')); run; options mprint mlogic; data _null_; set files end=last; call symputx(cats('dsn',strip(_n_)),in_name); call symputx(cats('outdsn',strip(_n_)),out_name); if last then call symputx('n',_n_); run; %do i=1 %to &n; proc import datafile="&location.\&&dsn&i." out= work.&&outdsn&i. dbms=dlm replace ; delimiter="~"; getnames=yes; run; %end; %mend; %test(c:\temp) Linlin
... View more