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:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.