What do you mean by a "database" - do you mean a single SAS dataset , or a group of datasets.
If you mean single dataset. Does the dataset has one common name? Or are they different?
[EDIT:] Does the "xxx" means one common root directory ?
Bart
Do you need to combine source data and run the analysis once, or run the complete analysis for each library, with separate results?
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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.