A libname can be something of the form:
LIBNAME x ('c:\dir1', 'c:\dir2', ..., 'c:\dirn');
So: LIBNAME x ('c:\data\2006\05', 'c:\data\2006\06', 'c:\data\2006\07');
Or you do something like:
DATA _NULL_;
LENGTH dir dirs $ 300;
DO yr = 2001 TO 2003; * year directory ;
DO m = 1 TO 12; * month directory;
dir = Quote(Trimn('c:\data\' ||Put(yr,4.0)||'\'||Put(m,z.2)));
IF dirs EQ '' THEN dirs = Trimn(dir);
ELSE dirs = Trimn(dirs) || ',' ||Trimn(dir) ;
END;
END;
Call SymPut('mdirs', dirs);
RUN;
LIBNAME f (&mdirs);
DATA x;
SET f.file1 f.file2 f.file3;
RUN;
Haven't tested this so you might have to spruce it up little, but you should get the idea. In particular, you could adapt the above to read inline data.
Depending on the version of SAS you're running, you can also put the name of file directly. But that's another time. Or homework.