You say LIBRARIES in your subject line. But in your text you appear to be talking about directories.
Do you have libref's defined that point to each of those directories?
Are you talking about SAS datasets in those different directories? What are the names of the datasets?
When you have datasets in many different directories sometimes it is easier to use the actual physical name of the dataset file instead of going to the trouble of defining a series of librefs.
data all_2023;
set "/xxx/202301/somedata.sas7bdat"
"/xxx/202302/somedata.sas7bdat"
"/xxx/202303/somedata.sas7bdat"
"/xxx/202304/somedata.sas7bdat"
"/xxx/202305/somedata.sas7bdat"
"/xxx/202306/somedata.sas7bdat"
"/xxx/202307/somedata.sas7bdat"
"/xxx/202308/somedata.sas7bdat"
"/xxx/202309/somedata.sas7bdat"
"/xxx/202310/somedata.sas7bdat"
"/xxx/202311/somedata.sas7bdat"
"/xxx/202312/somedata.sas7bdat"
;
run;
If there is a PATTERN to the names of the directories then you can use code to generate the directory names. For example if you wanted to generate the six digit string representing months in YYYYMM style then you could use a DO loop like this:
basedate = '01JAN2023'd;
do offset=0 to 11 ;
date = intnx('month',basedate,offset);
yymm = put(date,yymmn6.);
end;
Which if you needed that in macro code might look like:
%let basedate = '01JAN2023'd;
%do offset=0 %to 11 ;
%let date = %sysfunc(intnx(month,&basedate,&offset));
%let yymm = %sysfunc(putn(&date,yymmn6.));
%end;
... View more