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:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.