for Mr. Miller here's my complete script
data paths;
length path $200;
input path $;
datalines;
/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
/dwh_actuariat/sasprocess/prodmens/HYFIp/output
;
run;
/************************************************************/
%macro readfile(path,fname,suffix);
DATA &fname.;
INFILE "&path./&fname..&suffix";
INPUT Cie $ 1
province $ 2-3
branch $ 4-7
priorcur $ 8
polsrc $ 9
mois $ 10-15
lob $ 16-23
Trans $ 24-26
WP 27-41
EP 42-56
EU 57-71
WU 72-86
POLCNT 87-102
POLEARN 103-117
UW_CIE $ 118
DIST_CIE $ 119
OB_IND $ 120-124
BROKER_GROUP_IND $ 125-126
GCNA_BRANCH $ 127-128
POLICY_CATEGORY $ 129
NETWORK_PROVIDER $ 130-134
AFFINITY_IND $ 135
;
RUN;
%mend readfile;
/*******************************************************/
%macro readtxtfile;
%let yearmin=2024;
%let yearmax=2025;
%let prefix=HyFIPrems;
%let suffix=txt;
%let path=/dwh_actuariat/sasprocess/prodmens/HYFIprep/output;
%do year = &yearmin %to &yearmax;
%if &year. ne &yearmax. %then %let maxmonth=12;
%else %let maxmonth=7;
%do month =01 %to &maxmonth.;
%let formatted_month = %sysfunc(putn(&month, Z2.));
%let fname=&prefix.&year.&formatted_month.;
%put &fname..&suffix.;
%readfile(&path,&fname,&suffix);
PROC APPEND BASE=&prefix. DATA=&fname.;
RUN;
%end;
%end;
%mend readtxtfile;
/******************************************/
*%readtxtfile;
%macro readtxtfile2(path);
%let yearmin=2025;
%let yearmax=2025;
%let minmonth=1;
%let maxmonth=7;
%let prefix=HyFIPrems;
%let suffix=txt;
%do year = &yearmin %to &yearmax;
%do month =&minmonth. %to &maxmonth.;
%let formatted_month = %sysfunc(putn(&month, Z2.));
%let fname=&prefix.&year.&formatted_month.;
%put &fname..&suffix.;
%readfile(&path,&fname,&suffix);
%let substring=prep;
%if %sysfunc(find(&path. , &substring.)) > 0 %then
%do;
PROC APPEND BASE=&prefix. DATA=&fname.;
RUN;
%end;
%else
%do;
PROC APPEND BASE=&prefix._org DATA=&fname.;
RUN;
%end;
%end;
%end;
%mend readtxtfile2;
%macro process;
proc sql noprint;
select path into :path_list separated by ' '
from paths;
quit;
%put &=path_list;
%let i = 1;
%do %while (%qscan(&path_list, &i. ,%str( )) ne );
%let current_path = %scan(&path_list, &i. , %str( ));
%put &=current_path;
%readtxtfile2(¤t_path);
%let i = %eval(&i. + 1);
%end;
%mend process;
%process;
... View more