This is similar to the code posted by SBB, applied to your data example data. There is one important meta data missing "variable type". If your data included that information it would be more or less completly dynamic. That is the kind if think that PROC IMPORT does.
Anyway here if the code. I added a few files to further test the program for files with zero records.
[pre]
dm 'clear log; clear output;';
filename ft15f001 "%sysfunc(pathname(work))\abc.csv";
parmcards;
id, day, v1, v2, v3, v4
1, 1, VA, 100, 77, 0.23
2, 1, VA, 120, 44, 0.11
3, 1, VA, 135, 23, 0.45
;;;;
run;
filename ft15f001 "%sysfunc(pathname(work))\def.csv";
parmcards;
v1, x, id, v2, v3, v5, day, v4
VA, S, 1, 120, 35, 0.22, 2, 0.44
VA, S, 2, 110, 23, 0.01, 2, 0.33
VA, M, 3, 30, 21, 0.55, 2, 0.11
;;;;
run;
filename ft15f001 "%sysfunc(pathname(work))\ghi.csv";
parmcards;
id, day, v1, v2, v3, v4
1, 1, VA, 100, 77, 0.23
2, 1, VA, 120, 44, 0.11
3, 1, VA, 135, 23, 0.45
;;;;
run;
filename ft15f001 "%sysfunc(pathname(work))\jkl.csv";
parmcards;
;;;;
run;
filename ft15f001 "%sysfunc(pathname(work))\xyz.csv";
parmcards;
v2, v3, x, day, id
100, 23, M, 3, 1
120, 32, D, 3, 2
110, 43, D, 3, 3
;;;;
run;
data Fields;
length command filevar $128;
command = catx(' ','dir /s /b',quote(catx('\',pathname('WORK'),'*.csv')));
do while(not eof);
infile dummy1 pipe filevar=command end=eof;
input;
filevar = _infile_;
do while(1);
infile dummy2 filevar=filevar obs=1 truncover eof=eof;
input fields $128.;
output;
end;
eof:
end;
stop;
run;
proc sort data=work.fields nodupkey;
by fields;
run;
filename FT57F001 temp;
data _null_;
file FT57F001;
put +6 'select(fields);';
do until(eof);
set fields end=eof;
input = translate(fields,' ',',');
put +9 'When(' fields:$quote130. ') input ' input ';';
end;
put +9 'Otherwise;';
put +9 'End;';
stop;
run;
data all;
length command filevar filename $128;
command = catx(' ','dir /s /b',quote(catx('\',pathname('WORK'),'*.csv')));
length v1 x $8;
do while(not eof);
infile dummy1 pipe filevar=command end=eof;
input;
filevar = _infile_;
filename = scan(_infile_,-1,'\');
do while(1);
infile dummy2 filevar=filevar truncover eof=eof dsd;
input fields $128.;
do while(1);
%inc FT57F001;
output;
end;
end;
eof:
end;
stop;
run;
proc print;
run;
[/pre]