So you need to replace all occurrences of A_Sample with a macro variable, and then wrapthe code into a macro that accepts a parameter:
%macro import_text(fname);
data &fname.;
infile "C:\data\datasets\&fname..txt";
input
ID 1-16
FIRST_NAME $17-27
LAST_NAME $28 - 47
Phone_no 48 - 58
Activity_flag $59 - 59
;
Proc Sql;
create table &fname._test as
select * from &fname. where Activity_flag = 'Y';
Quit;
%if &sqlobs. = 0
%then %do;
proc delete data=
&fname.
&fname._test
;
run;
%end;
%mend;
%import_text(A_Sample)
You can now call this macro repeatedly from a dataset or from a text file with CALL EXECUTE:
data _null_;
set datasets;
call execute('%nrstr(%import_text('!!trim(fname)!!'))');
run;
... View more