options noxwait noxsync mlogic mprint;
x"dir dir D:\path\*.txt /b >d:\path.txt";
%macro a();
data temp1;
length x $50
fname $50;
infile"d:\path.txt";
input x $;
fname="D:\path\"||trim(left(x));
run;
data _null_;
set temp1 end=last;
call symputx("fname"||trim(left(_n_)),fname);
if last then do;
call symputx("nobs1",_n_);
end;
run;
%do i=1 %to &nobs1.;
data temp;
length %do j1=1 %to 1000; x&j1 $20 %end;;
infile"&&fname&i" dlm='09'x obs=1 missover ;
input %do j2=1 %to 1000; x&j2 $ %end;;
run;
data _null_;
set temp;
%do j3=1 %to 10;
call symputx("var_name_"||"&j3",x&j3);
%end;
run;
data data_&i.;
%do j4=1 %to 1000; %if &&var_name_&j4.^= %then %do; length &&var_name_&j4. $20 ; %end;%end;;
infile"&&fname&i" dlm='09'x missover firstobs=2;
input %do j5=1 %to 1000; %if &&var_name_&j5.^= %then %do ; &&var_name_&j5. $ %end;%end;;
run;
%end;
%mend;
%a();