Yes.
As Tom said these files are SAS dataset or CSV/TEXT files ?
We need to know the extension name of these files , so we can code something base on it .
I assumed these files were CSV files and the root folder of Country1,Country2,Country3 was "c:\temp\",
and you can use OS command too, otherwise you need to resort to the macro %dirtree written by @Tom to search all these sub-folders.
https://github.com/sasutils/macros/blob/master/dirtree.sas
%let root_folder= c:\temp ; *the parent path contains Country1,Country2,Country3 ;
%let want_excel = c:\temp\want.xlsx ; *the output excel file;
filename x pipe %sysfunc(quote(dir "&root_folder.\*.csv" /s /b ));
data path;
infile x length=len truncover;
input path $varying200. len;
dsn=cats(scan(path,-2,'\'),'_',scan(path,-2,'.\'));
id=scan(path,-2,'.\');
if lowcase(path) =: "&root_folder.\country";
run;
data _null_;
set path;
call execute(catt('proc import datafile="',path,'" out=',dsn,' dbms=csv replace;guessingrows=max;run;'));
run;
proc sort data=path out=id;
by id;
run;
data _null_;
set id ;
by id;
if first.id then call execute(cat('data ',id,';set '));
call execute(dsn);
if last.id then call execute(catt(";run;proc export data=",id," outfile='&want_excel.' dbms=xlsx replace;sheet='",id,"';run;"));
run;