Hi rogerjdeangelis, Thanks, I think I was almost there with your help. But would you please tell me what would be the right code. I am not getting three excel files with three different country name. Thanks.
libname xel "C:\Export to Multiple Excel Files";
DATA xel.Have;
INPUT Country $ Country_Code Region $;
DATALINES;
Japan 107 Asia
USA 109 America
France 103 Europe
Canada 111 America
India 105 Asia
Nepal 115 Asia
Italy 102 Europe
;
RUN;
libname xel "C:\Export to Multiple Excel Files/&country..xlsx";
data xel.&country;
set have(where=(country="&country"));
run;quit;
libname xel clear;
run;quit;
data have;
do country="CANADA ","GERMANY","USA";
do rec=1 to 5;
output;
end;
end;
run;quit;
%symdel country; *just in case you have this variable in global scope;
data _null_;
set have;
by country;
if first.country then do;
call symputx('country',compress(country,' .'),'g');
rc=dosubl('
libname xel "d:/xls/&country..xlsx";
data xel.&country;
set have(where=(country="&country"));
run;quit;
libname xel clear;
run;quit;
');
end;
run;quit;
... View more