Hi, community,
I am seeking an automatic way to read all SAS data in a folder to do the same process.
Thank you so much.
Here is my manual code. It works but takes time to key in all filenames.
/**/
Libname path "C:\myfolder\SAS";
Data &filename;
set path.&filename;
sas statements;
.
.
run;
%let filename=a;
%let filename=b;
............
proc sql;
select memname into :names separated by ' ' from dictionary.tables where upcase(libname)='PATH';
quit;
%macro dothis;
%do i=1 %to %sysfunc(countw(&names));
%let thisname = %scan(&names,&i,%str( ));
data &thisname;
set path.&thisname;
/* other sas statements */
run;
%end;
%mend;
%dothis
proc sql;
select memname into :names separated by ' ' from dictionary.tables where upcase(libname)='PATH';
quit;
%macro dothis;
%do i=1 %to %sysfunc(countw(&names));
%let thisname = %scan(&names,&i,%str( ));
data &thisname;
set path.&thisname;
/* other sas statements */
run;
%end;
%mend;
%dothis
So every dataset in the library has to be processed using the same statements. I am sure that such tasks have been solved many times - you will find them using the search function.
Here's just a recipe:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.